最近在IE10中開發(fā)jquery,關(guān)于jquery中combobox多選不能兼容的問題,進(jìn)行一些總結(jié)。
當(dāng)給combobox設(shè)置屬性“multiple:true”時(shí),IE10無法完成多選,其報(bào)錯(cuò)如下:
復(fù)制代碼 代碼如下:
function _7e8(_7e9,_7ea){
var _7eb=$.data(_7e9,"combobox");
var opts=_7eb.options;
var _7ec=$(_7e9).combo("getValues");
var _7ed=_7ec.indexOf(_7ea+"");//10650行 這里報(bào)錯(cuò)
if(_7ed>=0){
_7ec.splice(_7ed,1);
_7e7(_7e9,_7ec);
復(fù)制代碼 代碼如下:
<strong>function _7e8(_7e9,_7ea){
var _7eb=$.data(_7e9,"combobox");
var opts=_7eb.options;
var _7ec=$(_7e9).combo("getValues");
var _7ed = (function(arr,str){
str = str + "";
for(var i=0,l=arr.length;i<l;i++){
if(arr[i] == str) return i;
}
return -1;
})(_7ec,_7ea);
if(_7ed >= 0){//修改于 2013-6-25 19:04
_7ec.splice(_7ed,1);
_7e7(_7e9,_7ec);
}</strong>
復(fù)制代碼 代碼如下:
<strong>if(!Array.prototype.indexOf){
Array.prototype.indexOf = function(target){
for(var i=0,l=this.length;i<l;i++){
if(this[i] === target) return i;
}
return -1;
};
}</strong>
新聞熱點(diǎn)
疑難解答
圖片精選