下面是一個關於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]'。多謝你們! –