tags:

views:

31

answers:

1

I have form containing several options like this:

<label for="edit-attributes-2-29" class="option">
    <input type="checkbox"
          class="form-checkbox" value="29" 
          id="edit-attributes-2-29" name="attributes[2][29]">
    Cajunkryddad biffstek, +30 Kr
</label>

I need to select the whole surrounding div(not included above). when I use .html() I only get the labels and the text. not the input/checkbox.

Feels like something wrong. The whole thing is created by a php-script, so maybe that's the problem...

Someone got an idea?

+2  A: 

The problem is the markup, the <label> should be beside the <input>, not containing it, like this:

<input type="checkbox" class="form-checkbox" value="29" id="edit-attributes-2-29" name="attributes[2][29]">
<label for="edit-attributes-2-29" class="option"> Cajunkryddad biffstek, +30 Kr</label>
Nick Craver
Isn't it also valid for the `input` to be contained within the `label`?
Eric
@Eric - It can yes, but when you're *selecting* children (most often the case, not always) you want them as siblings. Is it valid? Yes, though technically you're not supposed to have the `for` attribute in that case...it's assumed to be for the *single* control element inside (only one can be within).
Nick Craver