我使用的是带有以下代码的Dual Listbox jQuery插件:
<div id="instructorSelTab" class="instructorSelTab"> <!-- start div instructorSelTab-->
<p class="iMsg">Please wait while the list of instructors is generated
<img class="iImg" src="&save_webPath.css/img/loader.gif" />
</p>
<table>
<tr>
<td>
<select id="i1View" multiple="multiple" style="height:300px;width:300px;"></select>
<br/>
</td>
<td>
<button id="ito2" type="button"> > </button><br />
<button id="iallTo2" type="button"> >> </button><br />
<button id="iallTo1" type="button"> << </button><br />
<button id="ito1" type="button"> < </button>
</td>
<td>
<select id="i2View" multiple="multiple" style="height:300px;width:300px;"></select>
<br/>
</td>
</tr>
</table>
</div> <!-- end div instructorSelTab -->
如何检查i2View的内容是否已更改?i2View中没有选择任何内容,我对内容不感兴趣,只是有些内容发生了变化。
更新:我已经尝试了以下内容:
$("#i1View, #ito2, #i2View").change(function(){
alert ('changed');
});
只有i1View会触发更改功能。
您可以在#i1View上放置一个更改函数,然后如果所选值为1(第二个值以0开头),则将触发您希望的命令。
$(document).ready(function() {
$("#i1View").change(function(){
if($("#i1View").find(":selected").val() == '1'){
$("#i1View").css('background','green');
}
else{
$("#i1View").css('background','red');
}
})
});