$(document).ready(function(){
$('input[type="radio"]').on('click',function(){
var name = $(this).attr("name");
$('input[type="radio"][name="'+name+'"]').closest(".radio").removeClass("new");
$(this).closest(".radio").addClass("new");
});
});
#4
0
You can include <label> element as parent of <input type="radio"> elements at html.
您可以在html中包含
The HTML Label Element (<label>) represents a caption for an item in a user interface. It can be associated with a control either by placing the control element inside the <label> element, or by using the for attribute. Such a control is called the labeled control of the label element. One input can be associated with multiple labels.
HTML标签元素(
The parent label element will be associated with :checked first child descendant input.
父标签元素将与:checked第一个子后代输入相关联。
You can style css:after pseudo element compounded to :checked selector to display blue border when input element is :checked.
If requirement is to use existing html, jQuery, you can utilize .click(), .toggleCLass() to add, remove "new"className if descendant input element checked property is false at click event, set inputchecked property to true
$(document).ready(function(){
$('input[type="radio"]').on('click',function(){
var name = $(this).attr("name");
$('input[type="radio"][name="'+name+'"]').closest(".radio").removeClass("new");
$(this).closest(".radio").addClass("new");
});
});
#4
0
You can include <label> element as parent of <input type="radio"> elements at html.
您可以在html中包含元素作为元素的父元素。
The HTML Label Element (<label>) represents a caption for an item in a user interface. It can be associated with a control either by placing the control element inside the <label> element, or by using the for attribute. Such a control is called the labeled control of the label element. One input can be associated with multiple labels.
If requirement is to use existing html, jQuery, you can utilize .click(), .toggleCLass() to add, remove "new"className if descendant input element checked property is false at click event, set inputchecked property to true