For example: Copy code The code is as follows:<input type="checkbox" id="a"><label for="a"><img src="..."></label> The effect we want to achieve is: click "Bank of China" and the checkbox will be selected (or cancelled). There is no problem in browsers such as FireFox and CHROME, but IE browser does not accept this. The solution is to use JS: Copy code The code is as follows:window.onload = function(){ if(document.all && navigator.appVersion.indexOf("MSIE")>-1 && navigator.appVersion.indexOf("Windows")>-1) { var a = document.getElementsByTagName("label"); for(var i=0,j=a.length;i<j;i++){ if(a[i].hasChildNodes && a[i].childNodes.item(0).tagName == "IMG") { a[i].childNodes.item(0).forid = a[i].htmlFor; a[i].childNodes.item(0).onclick = function(){ var e = document.getElementById(this.forid); switch(e.type){ case "radio": e.checked|=1;break; case "checkbox": e.checked=!e.checked;break; case "text": case "password": case "textarea": e.focus(); break; } } } } } } |
<<: Web Design Principles of Hyperlinks
>>: Detailed explanation of MySQL user rights management
You might be wondering why you should use the pat...
If we introduce the nesting rules of basic HTML w...
Table of contents 1. Get the value of browser coo...
Preface When operating and managing Linux servers...
1. Convert the json object into a json string, an...
Table of contents 1. MySQL join buffer 2. JoinBuf...
What is NFS? network file system A method or mech...
This article shares the specific code of jQuery t...
Tomcat is an HTTP server that is the official ref...
Often, after a web design is completed, the desig...
Project Documentation Directory Div+CSS Naming Sta...
Table of contents Class Component Functional Comp...
1. What is Docker Swarm? Docker Swarm is a cluste...
Enable remote access rights for mysql By default,...
1. Introduction Are you still leaving your websit...