Home >Web Front-end >JS Tutorial >Solution to click unresponsive and option unresponsive in ie8 mode
Click the option in the select and assign it to the input above, which is written directly with jQuery. The problem is that when it is opened in IE8, nothing happens when clicking the option.
The effect achieved is more common. Click the option in the select and assign it to the input above. It is written directly with jQuery:
$("#cardNoList option").click(function(){ $("#card").attr("value","").attr("value",this.value); })
There is a strange thing. Since the users basically use domestic dual-core browsers such as 360 Browser, with the addition of native Eclipse, the chrome kernel is used for parsing. When placed in the test environment, it becomes the IE8 standard for parsing.
Now here comes the question, learn to dig...well, no!
When opening it with IE8, nothing happens when clicking the option.
I tried adding alert:
$("#cardNoList option").click(function(){ alert("111"); $("#card").attr("value","").attr("value",this.value); alert("222"); })
click was not called at all.
At first, I thought it was a compatibility issue with jQuery's click event under IE8, but jQuery has encapsulated the compatibility and is widely used, so it shouldn't happen to me alone.
Later I thought that maybe the click was not added to the option in IE8. I changed it and added the click to the select. Now, IE8, Firefox, and Chrome can all assign values to the input smoothly.
$("#cardNoList").click(function(){ $("#card").attr("value","").attr("value",this.value); })
After searching on Baidu, it seems that "as we all know, in IE, the select option does not support onclick events" o(╯□╰)o
After being reminded, it was changed to:
$("#cardNoList").click(function(){ $("#card").val(this.value); }
The above is the entire content of this chapter. For more related tutorials, please visit jQuery Video Tutorial!