I am using the Spring form tag library in one of my projects and encountered the following problem:
I need to call a JavaScript function onmouseup on the label to a checkbox.
The problem is with the Spring form:checkbox tag the output then looks like this
<input id="id" name="name" value="true" type="checkbox">
<input name="_name" value="on" type="hidden">
<label for="id" onmouseup="func()" >blabla</label>
Due to my style.css which uses the + selector to get the label after a checked checkbox I need something like:
<input id="id" name="name" value="true" type="checkbox">
<label for="id" onmouseup="func()" >blabla</label>
<input name="_name" value="on" type="hidden">
But because I want to call a function onmouseup on the label, the label attribute to the form:checkbox tag won't work either.
My input is surrounded by a div so basically using the label attribute on the form:checkbox with the onmouseup call on the div would work but it feels kinda hacky.
So to sum it up I need either a different way to get my CSS to work or a way to achieve the above mentioned HTML structure using Spring.
The CSS (the rest is just styling which should not be important but I will post it if it'll help just let me know):
.switch input[type="checkbox"]:checked + label:after{
left: 23px;
}
.switch input[type="checkbox"]:checked + label{
background-color: #fff;
}