Using .end() for effective traversing


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $("
  2. <ul>
  3. <li> </li>
  4. </ul>
  5.  
  6. ") // li
  7. .find("a") // a
  8. .attr("href", "http://www.google.com/") // a
  9. .html("Google!") // a
  10. .end() // li
  11. .appendTo("ul");
  12.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.