Disable a class using Javascript?
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.
精彩评论