开发者

Check whether link's text is "B" then remove its class?

开发者 https://www.devze.com 2023-03-22 12:27 出处:网络
I want to check whether an a node contains开发者_JS百科 the word \"B\". If so, the node\'s someclass class should be removed.

I want to check whether an a node contains开发者_JS百科 the word "B". If so, the node's someclass class should be removed.

For example:

<a href="http://link.com" class="someclass">B</a>


$("a:contains('B')").removeClass('someclass');


$('a').click(function(){

   var text = $(this).text();

   if(text.indexOf("B")>= 0 ) {

         $(this).removClass('someclass');
   }

});
0

精彩评论

暂无评论...
验证码 换一张
取 消