Wednesday, 15 February 2012

jquery - How do I add a class to inner HTML of a div using Javascript? -


I'm trying to work around an impossible optimization for Wordpress. & lt ;? Php, the_category () ;? & Gt; prints:

  & lt; Ul class = "post-categories" & gt; & Lt; Li & gt; & Lt; A rel = "category-tag" title = "..." href = "..." & gt; Category A & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; e.t.c. & Lt; / Li & gt; & Lt; / Ul & gt;   

Let me give a class to all & lt; A & gt; is required to show, like this:

  & lt; Ul class = "post categories" & gt; & Lt; Li & gt; & Lt; One class = "btn" rel = "category-tag" title = "..." href = "..." & gt; Category A & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; e.t.c. & Lt; / Li & gt; & Lt; / Ul & gt;   

So far, I have discovered ways to provide additional classes with existing IDs or classes. Thanks, in advance, for your help!

Using jQuery:

  $ ("Post Categories a"). AddClass ("BTN");    

No comments:

Post a Comment