JQuery to find if any span inside label element

jquery

Solution

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);
}

Problem

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"/> ```

Original source