Without too much code, you can use hyperlinks to implement simple and beautiful custom check boxes

Without too much code, you can use hyperlinks to implement simple and beautiful custom check boxes
Today I suddenly thought that the styles of check boxes in HTML can be changed are limited, and it takes a lot of code to make a check box now, so I thought of a simple way to implement it. It has been fully proven that this is feasible. Without further ado, I will just post the source code for your reference.

Result:

When not selected: When selected:

Image background:

checkboxSel.jpg

checkboxNoSel.jpg

Code:

HTML code snippet:

Copy code
The code is as follows:

<a name="checkWeek" class="divCheckBoxNoSel"></a> Monday

javascript code snippet:

Copy code
The code is as follows:

$("a[name='checkWeek']").click(function(){
if($(this).hasClass('divCheckBoxSel')){
$(this).removeClass('divCheckBoxSel');
}else{
$(this).addClass('divCheckBoxSel');
}
});

CSS code snippet:

Copy code
The code is as follows:

.divCheckBoxNoSel{
background: url("../image/checkboxNoSel.jpg") no-repeat center center;
float:left;
width:15px;
height:15px;
border:1px solid #BDBDBD;
color:#FFF;
}
.divCheckBoxSel{
background: url("../image/checkboxSel.jpg") no-repeat center center;
float:left;
width:15px;
height:15px;
border:1px solid #BDBDBD;
color:#FFF;
}

There are many ways to distinguish each hyperlink, and in fact, radio button like text can also be easily realized in this way, thus saving time.

<<:  How to use Xtrabackup to back up and restore MySQL

>>:  How to use css overflow: hidden (overflow hiding and clearing floats)

Recommend

Usage instructions for the docker create command

The docker create command can create a container ...

Analysis of MySQL latency issues and data flushing strategy process

Table of contents 1. MySQL replication process 2....

Steps to set up and mount shared folders on Windows host and Docker container

Programs in Docker containers often need to acces...

Three ways to share component logic in React

Without further ado, these three methods are: ren...

How to build a multi-node Elastic stack cluster on RHEL8 /CentOS8

Elastic stack, commonly known as ELK stack, is a ...

Detailed explanation of JavaScript state container Redux

Table of contents 1. Why Redux 2. Redux Data flow...

MySQL multi-instance configuration application scenario

Table of contents MySQL multiple instances Multi-...

Tutorial on installing JDK Tomcat MySQL on Linux (remote access using Mac)

One environment Alibaba Cloud Server: CentOS 7.4 ...

A detailed account of the process of climbing a pit of Docker deployment service

First time writing. Allow me to introduce myself....

Reasons and solutions for MySQL failing to create foreign keys

When associating two tables, a foreign key could ...

Two ways to start Linux boot service

Table of contents rc.local method chkconfig metho...

Theory: The two years of user experience

<br />It has been no more than two years sin...