jQuery - Javascript para quem não sabe Javascript

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    jQuery - Javascript para quem não sabe Javascript - Presentation Transcript

    1. jQuery Javascript para quem não sabe Javascript Nando Vieira simplesideias.com.br
    2. A função mágica $(‘<seletor>’) = CSS + Javascript
    3. Seletores • $(‘#id’) • $(‘.class’) • $(‘a[rel=external]’) • $(‘ul > li:nth(5)’) • $(‘li:first’, parent) • ... e mais uma cacetada de seletores!
    4. Modificando elementos $(‘div’).css(‘width’, ‘100px’) $(‘div’).addClass(‘hidden’) $(‘div’).removeClass(‘hidden’) $(‘img’).attr(‘src’, ‘/some/image’)
    5. Modificando elementos $(‘div’).html(‘some <strong>html</strong>’) $(‘div’).append(‘more <strong>html</strong>’) $(‘div’).prepend(‘even <strong>more</strong>’) $(‘div’).before(‘<p>one line here...</p>’) $(‘div’).after(‘<p>... one more line!</p>’)
    6. Eventos • $(document).ready ou $(callback) • $(‘element’).click(callback) • $(‘element’).bind(‘click’, callback) A maioria dos métodos possui atalho: click, mouseover, mouseout, blur, focus...
    7. Callback • function do_something(){} • var do_something = function(){} • ... mas já pensou no tanto de funções que você terá que criar?
    8. Callback Função anônima é a solução! $(‘a’).click(function(){ //your code });
    9. Iterando em elementos $(‘element’).each(function(index){ //your code });
    10. Iterando em elementos Escopo $(‘a[rel=external]’).each(function(index){ alert(this); }); O objeto this sempre será o escopo do seletor, neste caso, a tag <a>.
    11. Iterando em elementos Escopo ATENÇÃO: this é Javascript puro! Use $(this) se precisar de qualquer funcionalidade do jQuery.
    12. Encadeamento de chamadas $(‘div’) .removeClass(‘hidden’) .html(‘some markup’) .fadeIn(‘normal’, function(){ alert(‘done’); });
    13. Quero ser web 2.0 Requisições HTTP (AJAX???) Só carregar HTML? Sem problema! $(‘div#content’).load(‘/some/html/content);
    14. Quero ser web 2.0 Requisições HTTP - GET $.get(‘/some/url’, function(content){ // do some processing $(‘div’).html(content); });
    15. Quero ser web 2.0 Requisições HTTP - POST $.post(‘/some/url’, function(content){ // do some processing $(‘div’).html(content); });
    16. Quero ser web 2.0 Requisições HTTP - JSON $.getJSON(‘/some/url’, function(data){ // do some processing alert(data.name); });
    17. Quero ser web 2.0 Requisições HTTP Métodos e Retorno de Dados $.ajax({ ‘url’: ‘/some/url’, ‘params’: {arg1: value1, arg2: ‘value2’}, ‘dataType’: ‘xml | json | html | jscript’, ‘success’: function(){}, ‘type’: ‘[http verbs]’ });
    18. Mais informações • http://visualjquery.com • http://docs.jquery.com • http://simplesideias.com.br/tags/jquery
    19. Dúvidas?
    SlideShare Zeitgeist 2009

    + fnandofnando Nominate

    custom

    1076 views, 2 favs, 1 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1076
      • 1074 on SlideShare
      • 2 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 35
    Most viewed embeds
    • 2 views on http://127.0.0.1

    more

    All embeds
    • 2 views on http://127.0.0.1

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories