How to use custom pictures to display checkbox in Html
Feb 10, 2017 am 10:23 AMThe following editor will bring you an article on how to use custom images in Html to display checkboxes. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look.
If you need to use pictures to implement the use of checkbox, you can use it. The implementation principle is to replace the display of the checkbox with the label table, and set the display of the checkbox to none. Use the image img to be displayed in the label tag, and then use the js function to control whether the image is selected or not.
JavaScript CodeCopy content to clipboard
<label for="agree" > <img class="checkbox" alt="选中" src="../img/checked.png" id="checkimg" onclick="checkclick();"> </label> <input type="checkbox" style="display:none" id="agree" checked="checked"> <script> function checkclick(){ var checkimg = document.getElementById("checkimg"); if($("#agree").is(':checked') ){ $("#agree").attr("checked","unchecked"); checkimg.src="../img/unchecked.png"; checkimg.alt="未选"; } else{ $("#agree").attr("checked","checked"); checkimg.src="../img/checked.png"; checkimg.alt="选中"; } } </script>
The above is a small The editor has brought you all the methods of using custom pictures to display checkboxes in Html. I hope you will support the PHP Chinese website~
More methods of using custom pictures to display checkboxes in Html For related articles, please pay attention to the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?

How do I use HTML5 form validation attributes to validate user input?

How to efficiently add stroke effects to PNG images on web pages?

What is the purpose of the <iframe> tag? What are the security considerations when using it?

What are the security implications of using iframes, and how can I mitigate them?

How do I use the HTML5 <meter> element to display numerical data within a range?

What are the best practices for cross-browser compatibility in HTML5?

How do I use HTML links effectively for navigation and SEO?
