check if label by a specific name exists,
Say if i want to find if such label exists
<label onClick='javascript:someMethod()' name="label_name">*some text*</label>
if so then i need to implement some code.
check if label by a specific name exists,
Say if i want to find if such label exists
<label onClick='javascript:someMethod()' name="label_name">*some text*</label>
if so then i need to implement some code.
尝试
var x = $('label[name="label_name"]');
if(x.length){
//label exists
}
在条件循环中试试这个 -- $('label[name="label_name"]').length
if($('label[name="label_name"]').length)
{
//code
}
if ($('label[name="label_name"]').length) {
alert('Label exists');
}
尝试这个:
$(document).ready(function(){
var name=$("label").attr("name");
});