Javascript MSIE在.mouseup()事件之前无法识别所选项目的更新
我有一个带有几个Javascript MSIE在.mouseup()事件之前无法识别所选项目的更新,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,我有一个带有几个列表的设置,允许您在上执行各种功能,具体取决于所选的功能。最初,我在上有一个.change()事件处理程序,它将首先在列表中找到所选元素,并相应地更新控件按钮的状态。(对于列表中的某些项目,某些功能应不可用) 然而,MSIE中.change()的奇怪行为我尝试了change(),它在IE/Mozilla/Chrome中工作 var selectList = $("#select"); var getCurrent = function(e) { currentSelec
列表的设置,允许您在
上执行各种功能,具体取决于所选的功能。最初,我在
上有一个.change()事件处理程序,它将首先在列表中找到所选元素,并相应地更新控件按钮的状态。(对于列表中的某些项目,某些功能应不可用)
然而,MSIE中.change()的奇怪行为我尝试了change(),它在IE/Mozilla/Chrome中工作
var selectList = $("#select");
var getCurrent = function(e) {
currentSelections = $("#select :selected");
vals = [];
for (var x = 0; x < currentSelections.length; x += 1) {
vals.push($(currentSelections[x]).html());
}
console.log(e, vals.join(', '));
}
selectList.change(function() {
getCurrent('click: ');
});
var selectList=$(“#选择”);
var getCurrent=函数(e){
currentSelections=$(“#选择:选定”);
VAL=[];
对于(var x=0;x
这里是指向JSFIDLE的链接
啊。。应该仔细阅读刚才看到的内容,因为它只适用于在IE
var selectList = $("#select");
var getCurrent = function (e) {
currentSelections = selectList.find(':selected');
var vals = [];
for (var x = 0; x < currentSelections.length; x += 1) {
vals.push($(currentSelections[x]).html());
}
console.log(e, vals.join(', '));
}
selectList.click( function () {
getCurrent('click: ');
});
selectList.mouseup( function () {
getCurrent('mouseup: ');
});
var selectList = $("#select");
var getCurrent = function (e) {
currentSelections = selectList.find(':selected');
var vals = [];
for (var x = 0; x < currentSelections.length; x += 1) {
vals.push($(currentSelections[x]).html());
}
console.log(e, vals.join(', '));
}
selectList.click( function () {
getCurrent('click: ');
});
selectList.mouseup( function () {
getCurrent('mouesup: ');
});
selectList.change( function () {
getCurrent('change: ');
});
if (selectList[0].attachEvent) {
selectList[0].attachEvent('onchange', function () {
getCurrent('onchange: ');
});
}
var selectList = $("#select");
var getCurrent = function(e) {
currentSelections = $("#select :selected");
vals = [];
for (var x = 0; x < currentSelections.length; x += 1) {
vals.push($(currentSelections[x]).html());
}
console.log(e, vals.join(', '));
}
selectList.change(function() {
getCurrent('click: ');
});