Home Web Front-end JS Tutorial Solution to click unresponsive and option unresponsive in ie8 mode

Solution to click unresponsive and option unresponsive in ie8 mode

May 16, 2016 pm 04:34 PM
click ie8

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); 
})
Copy after login

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"); 
})
Copy after login

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);
})
Copy after login

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);
}
Copy after login

The above is the entire content of this chapter. For more related tutorials, please visit jQuery Video Tutorial!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use v-on:click to monitor mouse click events in Vue How to use v-on:click to monitor mouse click events in Vue Jun 11, 2023 am 10:12 AM

Vue is a popular front-end framework that helps developers build websites and applications more conveniently and quickly. Among them, v-on:click is the instruction in Vue used to monitor mouse click events. Let's introduce how to use v-on:click in Vue to monitor mouse click events. First of all, using v-on:click in Vue can define mouse click events in two ways: directly in the template and in the Vue instance. Below we will introduce these two methods respectively. direct

How to solve the incompatibility prompt of vue ie8 How to solve the incompatibility prompt of vue ie8 Jan 29, 2023 am 10:20 AM

Solutions for vue ie8 incompatibility: 1. Use "babel-polyfill" to convert ES6 syntax to ES5; 2. Introduce "es6-promise"; 3. Prompt to upgrade the browser or pass "(function(w){if( !("WebSocket"in w&&2===w.WebSocket.CLOSING)){...}" Just jump to upgrade directly.

How to use v-on:click.self in Vue to trigger events only by yourself How to use v-on:click.self in Vue to trigger events only by yourself Jun 11, 2023 pm 01:57 PM

Vue is a popular front-end framework that is simple, efficient, and easy to maintain, and is loved by developers. In Vue, we often need to bind events to components or elements to achieve specific interactive effects, but sometimes we want the event to be triggered only by itself, without interference from other factors. So how to use v-on:click.self in Vue to trigger events only by yourself? This article will give you detailed answers. First, we need to understand the basic usage of the v-on instruction. The v-on directive is used to bind events, commonly used

What should I do if the 'click' event binding is invalid in my Vue application? What should I do if the 'click' event binding is invalid in my Vue application? Jun 24, 2023 pm 03:51 PM

Vue is a popular JavaScript framework for building modern web applications. In Vue, we usually use directives to operate DOM elements. Among them, the "click" event is one of the commonly used instructions. However, in Vue applications, we often encounter situations where the "click" event binding is invalid. This article explains how to solve this problem. The first step in checking whether an element exists is to confirm whether the element to which you want to bind a "click" event exists. If the element does not exist,

How to use v-on:click.capture to implement event processing in the capture phase in Vue How to use v-on:click.capture to implement event processing in the capture phase in Vue Jun 11, 2023 am 10:55 AM

Vue is a popular JavaScript framework that provides developers with a variety of instructions and methods, allowing developers to deal with various problems encountered in web development more efficiently. Among them, the v-on directive can be used to bind handlers for various events, and v-on:click.capture means that the capture phase is used when processing click events. In JavaScript, the event propagation process is divided into three stages: capture stage, target stage and bubbling stage. At the capture stage

Does ie8 support html5? Does ie8 support html5? Jan 06, 2023 pm 03:31 PM

IE8 does not support HTML5. If you want IE8 to support HTML5, there are two ways: 1. Reference Google's html5.js file and put the code in the head tag interval; 2. By adding "while (i--){document. createElement(e[i])}" code implementation supports HTML5 elements.

How to set ie8 compatibility mode and where? How to set ie8 compatibility mode How to set ie8 compatibility mode and where? How to set ie8 compatibility mode Mar 13, 2024 pm 06:31 PM

The IE8 browser is loved by many users, but when we log in to some websites or perform some operations, we need to set the compatibility mode. Let this site carefully introduce to users how to set the ie8 compatibility mode. IE8 compatibility mode setting method: 1. After opening the IE8 browser, select [Tools] in the top menu bar, and then click [Compatibility View Settings] in the pop-up options. 2. Click [Add] in the window that opens to add the URL you want to be compatible with. 3. Re-open the set webpage, and you will see an icon like a torn piece of paper behind the address bar, indicating that the compatibility mode has been set successfully. You can also see the compatibility mode in the drop-down menu of the tool.

How to use v-on:click.stop to stop event bubbling in Vue How to use v-on:click.stop to stop event bubbling in Vue Jun 11, 2023 pm 12:00 PM

Vue is a very popular JavaScript framework in the front-end community. It can help us build efficient, flexible and easy-to-maintain web applications. Event bubbling is a very common problem in Vue, because in complex applications, multiple components may share the same DOM element. In this case, it is very convenient to use the v-on:click.stop directive to stop event bubbling. 1. What is event bubbling? Event bubbling refers to when an event on a DOM element is triggered

See all articles