I remembered a small thing I had countless in elementary school. Alas, the running under the setting sun is my lost youth.
Let's get back to the point, let's take a picture:
<select id="cardNoList" size="4"></select>
A common effect is implemented. Click the option in select, assign it to the input above, and write it directly in jQuery:
The code copy is as follows:
$("#cardNoList option").click(function(){
$("#card").attr("value","").attr("value", this.value);
})
Something strange is
Since users are basically using domestic dual-core browsers such as 360 browser,
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
The native Eclipse run uses the chrome kernel for parsing. When placed in the test environment, it becomes the ie8 standard for parsing.
Now the problem is here, learn to dig... Uh, no!
When opening with IE8, clicking option has no response.
Garert and tried:
The code copy is as follows:
$("#cardNoList option").click(function(){
alert("111");
$("#card").attr("value","").attr("value", this.value);
alert("222");
})
Click is not called at all.
At first I thought it was a compatibility issue for jQuery's click event under ie8, but jQuery has encapsulated the compatibility and has solved it. It has such a wide application, so it would not be possible for me to encounter it.
Later I thought that it might be that click was not added to the option under ie8. After changing it, click was added to the select. It was done, and ie8, Firefox, and Chrome could all be assigned to the input smoothly.
The code copy is as follows:
$("#cardNoList").click(function(){
$("#card").attr("value","").attr("value", this.value);
})
Baidu found that it seems that "as we all know, in IE, the select option does not support the onclick event" o(□)o
After reminding, it was changed to:
The code copy is as follows:
$("#cardNoList").click(function(){
$("#card").val(this.value);
})