下面是一个关于IE的HTML编辑器的代码部分:如何在IE浏览器HTML编辑器中触发选择事件?
var selectStr = [];
selectStr.push("img[control_type='video']");
$(selectStr[0], document).selectionchange(function() {
alert();
}); // Explorer error: does not support this method or object.
// It seems JQuery does not support 'selectionchange' event.
document.onselectionchange = function(){
alert();
} // this works for all elements in the editor.
是否可以只适用于一个特定的元素?我tryied:
$(selectStr[0], document).onselectionchange = function(){
alert();
} // does not fire when selected.
alert($(selectStr[0], document)); // [object, object]
如果$(selectStr[0], document)
改为SOMETHING
,这样它会提醒[object, HTMLImgElement]
,这个问题将得到解决。任何人都知道如何以正确的方式做到这一点?
答案是'$(“img [control_type ='video']”,document)[0]'。多谢你们! –