Kaur Kaur - 23 days ago 6
jQuery Question

Is there any to hide the radio buttons but not the drop down list?

I have two radio buttons that I want to hide and just give the drop down list to the users to select from. Is it possible to hide the radio buttons completely without hiding the drop down list?

$("[name^=UseAllCodes]").parent().hide();
hides the dd list too.

<table>
<tr>
<td><input type="radio" name="UseAllCodes" value="yes" checked onClick="attReset();"> All<br>
<input type="radio" name="UseAllCodes" value="no" onClick="attReset();" id="theseCodes"> These codes <br>
<select name="handpick" onChange="attToggleAndReset();" size="10" multiple>
<option value="25248692">Code 1
<option value="25248693">Code 2
</select>
</td>
</tr>
</table>

Answer

If you can't change the original HTML, but you don't mind removing the radio buttons, rather than hiding them, you could do the following:

var $select = $("[name=handpick]");
var $cell = $select.parent();
$select.detach();
$cell.empty().append($select);

This detaches the select element, then clears out the table cell, and finally puts the select element back.

Comments