我试图在点击时找到下一个li
标签。checkbox
我尝试了一些方法(壁橱,父母)但得到未定义的错误。我已经创建了函数并将复选框 id 传递给它。这是我的代码
HTML
<li data-role="fieldcontain" id="liDoorConcerns" style="display: none;">
<fieldset data-role="controlgroup" data-role="fieldcontain">
<legend></legend>
<input type="checkbox" name="DoorMissing" id="DoorMissing" />
<label style="font-weight: bold; font-size: 14px" for="DoorMissing">Missing</label>
<input type="checkbox" name="DoorDamaged" id="DoorDamaged" />
<label style="font-weight: bold; font-size: 14px" for="DoorDamaged">Damaged</label>
<input type="checkbox" name="DoorBoardedUp" id="DoorBoardedUp" />
<label style="font-weight: bold; font-size: 14px" for="DoorBoardedUp">Boarded up</label>
<input type="checkbox" name="DoorPaint" id="DoorPaint" />
<label style="font-weight: bold; font-size: 14px" for="DoorPaint">Paint</label>
<input type="checkbox" name="DoorDryRot" id="DoorDryRot" />
<label style="font-weight: bold; font-size: 14px" for="DoorDryRot">Dry Rot</label>
<input type="checkbox" name="DoorOther" id="DoorOther" />
<label style="font-weight: bold; font-size: 14px" for="DoorOther">Other</label>
</fieldset>
</li>
<li data-role="fieldcontain" id="liDoorConcernsComments" style="display:none;">
<fieldset data-role="controlgroup" data-role="fieldcontain">
<legend></legend>
<textarea cols="20" id="DoorConcernsComments" name="DoorConcernsComments" rows="2"></textarea>
</fieldset>
</li>
JS代码:
function test(ida) {
debugger;
var element = $('#' + ida);
var get = element.find('li');
var li_id = get.first().id;
alert("id" + li_id);
}