html - How can a CSS id style be accessed in jquery? -


I'm new to jquery and do not know how to add CSS ID to a page element.

  #main h2 {background: url (open.png) no-repeat 0% 10%; Padding-left: 20px; Cursor: indicator; } #hahana h2.close {background-image: url (close.png); } #hana h2.highlight {color: red; font-weight: bold; Text-transform: uppercase; }   

And here I have tried jquery:

  $ (document) .ready (function () {$ ("h2"). AddClass ( '#main h2.highlight');   

It certainly works with orbits but I can not understand how to get the styles on the h2 tag.

Here's a lame, but:

  $ ('# main h2' ) AddClass ('Highlight');   

Highlight class to & lt; h2 & gt; element < / Em> will add (descendant) ID main Element Elements Effectively & lt; h2 & gt; make rules to rule (rules) #main h2.highlight . Does this object If not, please note.

Comments