tags:

views:

375

answers:

3

Hi,

I am using JQuery for my application .

I am having a html as

<label id="label1">Firstname<span class="req"><em> * </em></span></label>

In my JQuery code i want to check is there any span like tag inside label and if exists ,i want to keep my check box On.how to do so ..Please suggest me.

The following is my checkbox

 <input id="required" type="checkbox" name="required"/>
+4  A: 

Use this to check if there are any spans with a class of req, inside a label. If so, set the checkbox with id required to checked.

if($("label > span.req").length > 0)
{
    $("#required").attr("checked", true);
}
alexn
+2  A: 
$("#required").attr("checked", !!$("#label1 span.req").length )
duckyflip
A: 

ik heb kanker godverdomme :s