Answer the question
In order to leave comments, you need to log in
How to package the process of clicking on a list item more compactly and correctly?
I greet all gurus, guress, gurus and those passing by!
I have a piece of crooked code in js, its essence is simple: when you click on the switch, its value is entered in a hidden input field:
$('#list > li input').click(function () {
if (checkType('radio') == 1) {
document.getElementById("field").value = "Значение 1"
}
if (checkType('radio') == 2) {
document.getElementById("field").value = "Значение 2"
}
if (checkType('radio') == 3) {
document.getElementById("field").value = "Значение 3"
}
});
<ul id="list">
<li>
<label>
<input type="radio" name="radio" value="1">
<span>Значение 1</span>
</label>
</li>
<li>
<label>
<input type="radio" name="radio" value="2">
<span>Значение 2</span>
</label>
</li>
<li>
<label>
<input type="radio" name="radio" value="3">
<span>Значение 3</span>
</label>
</li>
</ul>
<input type="hidden" id="field" value="">
Answer the question
In order to leave comments, you need to log in
Maybe there are too many versions of jQuery stuffed in, so they conflict.
Most likely, jQuery or one of its plugins has been forgotten. I won’t tell you, because the telepaths dumped everything on vacation
Have you correctly connected the scripts to WP? Through registration of scripts?
If not by the method recommended by the WP developers, then the scripts can be connected in a different order. Because of this, the conflict.
Function for registration - wp_register_script( params );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question