JQuery: select elements where align = "center"

I am trying to select only paragraphs where align = "center" (inline style).

jQuery(p.MsoNormal).attr('align', 'center').addClass('av-tablecell');

It seems that you select all paragraph elements, even without align = center.

+3
source share
2 answers

Your code sets the "align" attribute on p.MsoNormal to "center". You must include it in your selection to get only those elements that already have "align = center", for example:

jQuery('p.MsoNormal[align="center"]').addClass('av-tablecell');
+1
source

Try for example

jQuery('p.MsoNormal[align=center]').addClass('av-tablecell');
+5
source

All Articles