Think of the elementary school time countless a small thing, hey, that sunset under the run, is my lost youth ah.
Anyway, let's go ahead and figure out:
<select id= "Cardnolist" size= "4" ></select>
The effect of the implementation of a more common one, click the Select option, assign it to the above input, directly in jquery write:
Copy Code code as follows:
$ ("#cardNoList option"). Click (function () {
$ ("#card"). attr ("Value", ""). attr ("value", this.value);
})
There's a strange thing,
Because the user is basically the use of 360 browsers such as domestic dual-core browser, add a
<meta http-equiv= "x-ua-compatible" content= "ie=edge,chrome=1"/>
The native eclipse run is parsed by the chrome kernel and placed in the test environment, which becomes the IE8 standard.
Now the problem comes, learn to dig ... Uh, no!
When opened with IE8, click option without any response.
Plus alert tried the following:
Copy Code code as follows:
$ ("#cardNoList option"). Click (function () {
Alert ("111");
$ ("#card"). attr ("Value", ""). attr ("value", this.value);
Alert ("222");
})
Click Not called at all.
The first thought was the compatibility of jquery click events under the IE8, but jquery compatibility is packaged and applied so widely that I'm not supposed to encounter.
Later thought, may be under the IE8 click simply did not add to option above, changed, will click Add to select, became, IE8, Firefox, Chrome can be successfully assigned to input.
Copy Code code as follows:
$ ("#cardNoList"). Click (function () {
$ ("#card"). attr ("Value", ""). attr ("value", this.value);
})
Baidu, seemingly "well-known, in IE, select option is not support onclick event" O (╯-╰) o
By reminder, replace the following:
Copy Code code as follows:
$ ("#cardNoList"). Click (function () {
$ ("#card"). Val (This.value);
})