假设我有以下运行脚本:(http://jsfiddle.net/raidnet/AcuU3/)
JS
$(document).bind("pageinit", function (event, data) {
$(".group2").hide();
$('#flip2').on('change', function () {
var regtype = $("#flip2").val();
if (regtype == "0") {
$(".group2").hide();
} else {
$(".group2").show();
}
});
});
HTML
<ul data-role="listview" data-inset="true">
<!-- group A -->
<li data-role="fieldcontain">
<label for="flip2">FLIP 2 Label:</label>
<select name="flip2" id="flip2" data-role="slider" data-mini="true">
<option value="0">NO</option>
<option value="1">SI</option>
</select>
</li>
<li data-role="fieldcontain" class="group2">
<label for="name2" class="ui-hidden-accessible group2">FLIP 2A</label>
<input type="text" class="group2" name="name2" placeholder="FLIP 2A" id="name2" data-mini="true" value="" data-clear-btn="true">
</li>
<!-- group B -->
<li data-role="fieldcontain">
<label for="flip3">FLIP 3 Label:</label>
<select name="flip3" id="flip3" data-role="slider" data-mini="true">
<option value="0">NO</option>
<option value="1">SI</option>
</select>
</li>
<li data-role="fieldcontain" class="group3">
<label for="name3" class="ui-hidden-accessible group3">FLIP 3A</label>
<input type="text" class="group3" name="name3" placeholder="FLIP 3A" id="name3" data-mini="true" value="" data-clear-btn="true">
</ li>
<!-- group H -->
</ ul>
该脚本适用于 1 个 select 元素,但如果我有更多的一组 select + input 元素让我们说 10,我该如何增强 java 脚本?如何将所选字段中的 id 传递给脚本?