Summary of incompatibility issues with multiple choice of combobox in jquery _ jquery-js tutorial

Source: Internet
Author: User
I recently developed jquery in IE10. I would like to summarize the incompatibility between multiple choice combobox and combobox in jquery. If you are interested, I would like to know how to develop jquery in IE10 recently, the compatibility of multiple choice of combobox in jquery is summarized.

When the attribute "multiple: true" is set for combobox, IE10 cannot complete multiple selections. The error is as follows:

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 + ""); // an error is returned in row 10650.
If (_ 7ed> = 0 ){
_ 7ec. splice (_ 7ed, 1 );
_ 7e7 (_ 7e9, _ 7ec );


That is to say, the indexOf method is not supported in F12. There are two solutions to this problem:

1. modify source code

Modify the above 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; I If (arr [I] = str) return I;
}
Return-1;
}) (_ 7ec, _ 7ea );
If (_ 7ed> = 0) {// modified
_ 7ec. splice (_ 7ed, 1 );
_ 7e7 (_ 7e9, _ 7ec );
}


2. Add the indexOf Method

The Code is as follows:


If (! Array. prototype. indexOf ){
Array. prototype. indexOf = function (target ){
For (var I = 0, l = this. length; I If (this [I] === target) return I;
}
Return-1;
};
}


In fact, I recommend the first method, because it is more convenient, I am using the first method.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.