docs:jquery:quickref

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docs:jquery:quickref [2011/11/07 20:50] – created billhdocs:jquery:quickref [2013/02/05 15:06] (current) billh
Line 4: Line 4:
 $(document.ready(function(){ $(document.ready(function(){
   // code goes here   // code goes here
 +});
 +
 +// prevent caching ajax requests
 +$.ajaxSetup({
 + cache: false
 }); });
  
Line 41: Line 46:
  
 // prev(), next(), parent(), children(), nextAll(), prevAll() // prev(), next(), parent(), children(), nextAll(), prevAll()
-$('li:eq(3)').prev()               // <<<--- element at eq(2) +$('li:eq(3)').prev()                      // <<<--- element at eq(2) 
-$('li:eq(3)').next()               // <<<--- element at eq(4) +$('li:eq(3)').next()                      // <<<--- element at eq(4) 
-$('li:eq(3)').parent()             // <<<--- ul or ol element holding the li's +$('li:eq(3)').parent()                    // <<<--- ul or ol element holding the li's 
-$('li:eq(3)').parent().children()  // <<<--- all li's in this list +$('li:eq(3)').parent().children()         // <<<--- all li'in this list 
-$('li:eq(3)').nextAll()            // <<<--- all elements following eq(4) +$('li:eq(3)').parent().children(':last' // <<<--- the last li in this list 
-$('li:eq(3)').prevAll()            // <<<--- all elements before eq(4)+$('li:eq(3)').nextAll()                   // <<<--- all elements following eq(4) 
 +$('li:eq(3)').prevAll()                   // <<<--- all elements before eq(4) 
  
 // trim whitespace from ends of a string value // trim whitespace from ends of a string value
Line 55: Line 62:
  
 // create html elements and add them to the page // create html elements and add them to the page
 +// see also: append(), prepend(), prependTo(), after(), before(), insertAfter(), insertBefore()
 +// wrap(), wrapAll(), wrapInner()
 $('<p><a>jQuery</a></p>').find('a').attr('href', 'http://www.jquery.com').end().appendTo('body') $('<p><a>jQuery</a></p>').find('a').attr('href', 'http://www.jquery.com').end().appendTo('body')
 +
 +// remove html elements from the page
 +$('a.someclass').remove()
 +
 +// replacing elements
 +$('span.original').replaceWith('<span>new</span>')
 +$('<span>new</span>').replaceAll('span.original')
 +
 +// cloning elements
 +$('span.someclass').clone().appendTo('body')
 +
 +// cloning elements, including events (passing true to clone())
 +// notice that this one adds a clone of a button, then removes the original
 +$('button:first').clone(true).appendTo('body').end().end().remove()
 </code> </code>
  
  • docs/jquery/quickref.1320724229.txt.gz
  • Last modified: 2011/11/07 20:50
  • by billh