How to select display:none labels from the div
i want to select all labels inside a div that are only apply style display:none
labels like below
<label for="txtAmount_146" generated="true" class="errortd" style="display: none; ">This field is required.</label>
i tried
if($('.errortd', this).not(':hidden')){
开发者_运维知识库 alert($(this).text())
}
I have no luck still any help
You want to select all labels that have "display:none" and do something, right?
Consider this html:
<div id="something">
<label class="errortd" style="display: none; ">This field is required 1.</label>
<label class="errortd" >This field is required 2.</label>
<label class="errortd" style="display: none; ">This field is required 3.</label>
</div>
You can alert the text of the first and third label with this:
$(function(){
$('#something label:hidden').each(function(){
alert( $(this).text() );
});
});
This should do it
$("label:hidden", "div")...
So to do something like you do in your example do:
$("label:hidden", "div").each(function(i) { alert($(this).text();});
精彩评论