开发者

Disable a class using Javascript?

开发者 https://www.devze.com 2023-01-12 19:04 出处:网络
I am using a e-commerce package and there are sections my client wants disable to hidden.The problem is the package has all their labels under the same class and I am not sure how I can target certain

I am using a e-commerce package and there are sections my client wants disable to hidden. The problem is the package has all their labels under the same class and I am not sure how I can target certain ones in order 开发者_高级运维to hide or disable them.

I have 5 and would like to hide the 3rd one, lets say. They are in a table to so it looks just like this:

<td><span class="lable">Description</span></td>

any suggestions?


Since you've tagged this as jQuery, then the eq, gt and lt selectors may be of interest to you:

$("tr > td > span[class=lable]:eq(2)").hide();

Demo: http://jsfiddle.net/6MvnB/

and: http://jsfiddle.net/LD6nU/ (courtesy of @Majid)


$('.label').eq(2).hide()

Prefer the the list selection methods like eq() to the non-standard selectors like :eq. Using the jQuery selectors makes the browser fall back to the relatively slow Sizzle selector library instead of the fast native querySelectorAll() support built into modern browsers.

0

精彩评论

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

关注公众号