lolcat lolcat - 3 months ago 10
HTML Question

Hide line of descriptive list

The following is my situation:

I have a page that is dynamically created with a descriptive list of texts with accompanying checkboxes.

I can check whether a checkbox is created through it having the attribute of "checked" when a page is loaded.
Such a checkbox is always situated in a < dd >-element with an accompanying < dt >-element.

Can i remove/hide this line of dd & dt without any other identifying aides like id's or classes by using JS or JQuery ?

See a code-example below for clarification of the piece of the list i wand to hide if checked="checked" for the input:

<dt>Some descriptive text</dt>
<dd>
<input disabled="disabled" type="checkbox" name="somename" checked="checked">
</dd>

Answer

So for anyone interested in the solution, this is how i solved it:

if(document.getElementById('thePage')){
    $("[checked=checked]").parent().prev().hide();
    $("[checked=checked]").hide();
}