Home > Web Front-end > JS Tutorial > Summary of incompatibility issues with combobox multiple selection in jquery_jquery

Summary of incompatibility issues with combobox multiple selection in jquery_jquery

WBOY
Release: 2016-05-16 17:07:20
Original
1634 people have browsed it

Recently, I was developing jquery in IE10. I made some summary about the incompatible problem of combobox multi-selection in jquery.

When setting the attribute "multiple:true" for the combobox, IE10 cannot complete the multiple selection, and the error is as follows:

Copy code The code is as follows:

function _7e8(_7e9,_7ea){
var _7eb=$.data(_7e9,"combobox");
var opts=_7eb.options ;
var _7ec=$(_7e9).combo("getValues");
var _7ed=_7ec.indexOf(_7ea "");//Error reported here at line 10650
if(_7ed>=0) {
_7ec.splice(_7ed,1);
_7e7(_7e9,_7ec);

That is, it is reported that the indexOf method is not supported in F12. Now there are two solutions to this problem Solution:

1. Modify the source code

Modify the above code to
Copy the code The code is as follows:

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;iif(arr[i] == str) return i;
}
return -1;
})(_7ec ,_7ea);
if(_7ed >= 0){//Modified on 2013-6-25 19:04
_7ec.splice(_7ed,1);
_7e7(_7e9,_7ec);
}


2. Add indexOf method
Copy code Code As follows:

if(!Array.prototype.indexOf){
Array.prototype.indexOf = function(target){
for(var i=0,l =this.length;iif(this[i] === target) return i;
}
return -1;
};
}< ;/strong>

Actually, I quite recommend the first method, because it is more convenient, so I use the first method.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template