[英]Internet Explorer 10 - jQuery click on select option doesn't work
[英]jQuery script doesn't work in Internet Explorer 10
当我选择需要激活按钮的选项时,它可以在除IE10之外的所有浏览器中使用。
选择的html:
<select id="tenants" name="tenants" size="10" class="reportOption" onchange="">
<option value="DSF-sdfdsfdsf" id="9" onclick="">DSF-sdfdsfdsf</option>
<option value="HLQ - Harlequin North America" id="6" onclick="">HLQ - Harlequin North America</option>
<option value="HMB - Harlequin Mills and Boone" id="7" onclick="">HMB - Harlequin Mills and Boone</option>
<option value="HQA - Harlequin Australia" id="8" onclick="">HQA - Harlequin Australia</option>
<option value="KPC - Kensington" id="5" onclick="">KPC - Kensington</option>
<option value="LDD - Libre Digital Inc." id="1" onclick="">LDD - Libre Digital Inc. </option>
<option value="SCH - Scholastic Inc." id="2" onclick="">SCH - Scholastic Inc.</option> <option value="SSH - Simon and Shusterman" id="4" onclick="">SSH - Simon and Shusterman</option>
</select>
按钮html:
<div class="reportsButtons left_setup_buttons">
<input type="button" id="addCtgBtn" class="button setup_btn" value="New"/>
<input type="button" id="editCtgBtn" class="button setup_btn disabled" disabled value="Edit" onclick="showAddCategoryForm(this);"/>
<input type="button" id="delCtgBtn" class="button setup_btn disabled" disabled value="Delete" onclick="deleteCategory(this);"/>
</div>
而我的JS:
$("#categories option").click(function(){
$("#categories option").removeClass('selected');
$(this).addClass('selected');
selectedCategoryId=$(this).attr('id');
selectedCategoryName = $(this).attr('value');
$('#editCtgBtn, #delCtgBtn').removeAttr("disabled").removeClass("disabled");
$("#addCtg").hide();
});
尝试更改而不是单击。
//$("#categories")
$("#tenants").change(function(){
var selectedOption = $(this).find("option:selected");
$(this).find('option').removeClass('selected');
selectedOption.addClass('selected');
selectedCategoryId=selectedOption.attr('id');
selectedCategoryName = $(this).val();
$('#editCtgBtn, #delCtgBtn').removeAttr("disabled").removeClass("disabled");
$("#addCtg").hide();
});
注意选择的名称
编辑您的代码
$("#tenants").change(function(){
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.