当我选择选项时,我需要激活按钮,它在不包括IE10的所有浏览器中都能工作。
Select的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();
});发布于 2014-03-24 17:12:51
尝试改变而不是点击..。
//$("#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();
});发布于 2014-03-24 17:14:49
注意select的名称
编辑您的代码
$("#tenants").change(function(){https://stackoverflow.com/questions/22616031
复制相似问题