Saturday, May 9, 2009

jQuery quick notes

Here is some quick notes while handling jQuery.

   1: // Locates all elements with type=Text
   2: $("input[type=text]")
   3:  
   4: // Selects all <div> element with 'title' attributes
   5: // whose value begins with 'my'
   6: $("div[title^=my]")
   7:  
   8: // Locates all links that refers PDF
   9: $("a[href$=.pdf]")
  10:  
  11: // Locates anchor elements having the value
  12: // someurl.com anywhere in the 'href' attribute
  13: $("a[href*=someurl.com]")
  14:  
  15: // Locates all the achor tags
  16: // coming inside a li tag
  17: $("li:has(a)")
  18:  
  19: // Locates anchor(a) tags inside a paragraph(p) tag
  20: // where anchor-tag having a cssClass="someCssClass"
  21: $("p a.someCssClass")
  22:  
  23: // Matches all anchor(a) tags
  24: $("a")
  25:  
  26: // Matches element having an id=someId
  27: $("a#someId")
  28:  
  29: // Matches all elements having a CssClass=someCssClass
  30: $(".someCssClass")
  31:  
  32: // Locates anchor(a) tag with Id=someId and cssClass=someCssClass
  33: $("a.someId.someCssClass")

Reference: Manning’s jQuery in Action.


I must say, it’s a must read book.

Thanks.

No comments:

 
Best viewed in Internet Explorer 8.