Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery : check if label by a specific name exists

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.

like image 764
Garry Avatar asked Apr 19 '13 09:04

Garry


4 Answers

Try This in condition loop -- $('label[name="label_name"]').length

like image 192
Kumar Gaurish Avatar answered Nov 19 '22 18:11

Kumar Gaurish


Try

var x = $('label[name="label_name"]');
if(x.length){
    //label exists
}
like image 36
Arun P Johny Avatar answered Nov 19 '22 19:11

Arun P Johny


if ($('label[name="label_name"]').length) {
    alert('Label exists');
}
like image 3
powtac Avatar answered Nov 19 '22 18:11

powtac


if($('label[name="label_name"]').length)
{
    //code
}
like image 3
shakib Avatar answered Nov 19 '22 18:11

shakib