Home  >  Article  >  Web Front-end  >  Solution to the problem of double-clicking the checkbox response delay under IE_javascript skills

Solution to the problem of double-clicking the checkbox response delay under IE_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:54:171343browse
Copy code The code is as follows:



The above code will generate a multi-select box under IE. Clicking it will select the check box. Click it again The check will be cancelled.

There seems to be nothing wrong with this, but if you try to click this button twice quickly (a little slower than double-clicking...), the effect may not be as you imagine.

Under IE, if the checkbox is selected at this time, when you click twice quickly, the first click will cause the checkbox to be unchecked, and after the second click, the checkbox will not be selected. will become selected, but will remain unselected.

In browsers such as Chrome, the first click will uncheck the checkbox, and the checkbox will return to the selected state after the second click.

So under IE, after double-clicking, the checkbox will change to the opposite state. Under non-IE, the checkbox is in the same state after double-clicking.

If you want to double-click the checkbox under IE to achieve the effect of non-IE, you need to use the following code:
Copy code The code is as follows:


$("input[type='checkbox']").attr('ondblclick', ' this.click()');
Statement:
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