Advertisement
alex1984vn

jQuery

Mar 16th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  2. <script>
  3. $(document).ready(function(){
  4.   $("p").click(function(){
  5.     $(this).hide();
  6.   });
  7. });
  8. </script>
  9. ========
  10. $(this).hide() - hides the current element.
  11. $("p").hide() - hides all <p> elements.
  12. $(".test").hide() - hides all elements with class="test".
  13. $("#test").hide() - hides the element with id="test".
  14. ========
  15. Syntax  Description     Example
  16. $("*")  Selects all elements    Try it
  17. $(this)     Selects the current HTML element    Try it
  18. $("p.intro")    Selects all <p> elements with class="intro"     Try it
  19. $("p:first")    Selects the first <p> element   Try it
  20. $("ul li:first")    Selects the first <li> element of the first <ul>    Try it
  21. $("ul li:first-child")  Selects the first <li> element of every <ul>    Try it
  22. $("[href]")     Selects all elements with an href attribute     Try it
  23. $("a[target='_blank']")     Selects all <a> elements with a target attribute value equal to "_blank"    Try it
  24. $("a[target!='_blank']")    Selects all <a> elements with a target attribute value NOT equal to "_blank"    Try it
  25. $(":button")    Selects all <button> elements and <input> elements of type="button"     Try it
  26. $("tr:even")    Selects all even <tr> elements  Try it
  27. $("tr:odd")     Selects all odd <tr> elements   Try it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement