欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在jquery中combobox多選的不兼容問(wèn)題總結(jié)

 更新時(shí)間:2013年12月24日 16:06:47   作者:  
最近在IE10中開(kāi)發(fā)jquery,關(guān)于jquery中combobox多選不能兼容的問(wèn)題,進(jìn)行一些總結(jié),感興趣的朋友可以了解下
最近在IE10中開(kāi)發(fā)jquery,關(guān)于jquery中combobox多選不能兼容的問(wèn)題,進(jìn)行一些總結(jié)。

當(dāng)給combobox設(shè)置屬性“multiple:true”時(shí),IE10無(wú)法完成多選,其報(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);

也就是在F12中報(bào)不支持indexOf方法,現(xiàn)在對(duì)這種問(wèn)題有兩種解決方案:

1.修改源碼

將以上代碼修改為
復(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>

2.加入indexOf方法
復(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>

其實(shí)我還是蠻推薦第一種方法的,因?yàn)楸容^方便,我就是用的第一種方式。

相關(guān)文章

最新評(píng)論