In some page, my side menu is created dynamically like this.
<div id="tree" class="treeview">
<ul><li><a href="Salg.asp" title="" class="">Salg</a></li>
<li><a href="Retur.asp" title="" class="">Retur</a></li>
<li><a href="Support.asp" title="" class="active">Support</a> </li>
<li><a 开发者_StackOverflow中文版href="konomi.asp" title="" class="">Økonomi</a></li>
</ul>
</div><!-- end of tree treeview -->
In other page all the list have different text such as product categories etc.
Now I need to add padding to li in the menu where list texts are Salg, Retur, Support, and Økonomi.
This means I need to add a class "listpad" to li where the texts are Salg, Retur, Support, and Økonomi.
Could anyone tell me how to do this please?
Thanks in advance.
You can use the :contains
filter selector for that like this:
$('ul#tree li:contains("Salg")').addClass('listpad');
$('ul#tree li:contains("Retur")').addClass('listpad');
$('ul#tree li:contains("Support")').addClass('listpad');
$('ul#tree li:contains("Økonomi")').addClass('listpad');
精彩评论