views:

18

answers:

2

In jquery is it possible to access a select element by simply using the div or span id plus the "select" selector? I ask because i have a series of auto-generated forms meaning I can't assign an id to the form elements plus the names are weird like "w24", I'd like to access a form element specifically a select using the surrounding span id and "select" selector example:

$("#hiv_care select").attr("disabled",true);

I've tried this but it doesn't work, forcing me to explicitly use the dropdown name.

A: 

Your code should work fine.

Please show us your HTML.

SLaks
<td><span id="hiv_care"><select id="w16" name="w16"><option value="" selected="true"></option><option value="1065">YES</option><option value="1066">NO</option><option value="1067">UNKNOWN</option></select> <span class="error" style="display: none" id="w15"></span></span></td>
jwesonga
A: 

Seems I was using the wrong div id. SLaks thanks for the link to jsfiddle.net it exposed my ways and is really helping me with testing out my jquery code.

jwesonga