[英]radio button check selection change event in jquery
this is my html这是我的 html
<div id="options_div">
<input name="Names" type="radio" class="VoteAns" id="VoteAns_269_1" value="Values" contenteditable="false"/>
<label id="VoteAns_269_1_lbl" contenteditable="true">6 : 00 PM</label>
<label id="VoteAnsOP_269_1"></label><br>
<input name="Names" type="radio" class="VoteAns" id="VoteAns_269_2" value="Values" contenteditable="false"/>
<label contenteditable="true">7 : 00 PM</label>
<label id="VoteAnsOP_269_2"></label><br>
<input name="Names" type="radio" class="VoteAns" id="VoteAns_269_3" value="Values" contenteditable="false"/>
<label contenteditable="true">8 : 00 PM</label>
<label id="VoteAnsOP_269_3"></label><br>
<input name="Names" type="radio" class="VoteAns" id="VoteAns_269_4" value="Values" contenteditable="false"/>
<label contenteditable="true">9 : 00 PM</label>
<label id="VoteAnsOP_269_4"></label><br>
<input name="Names" type="radio" class="VoteAns" id="VoteAns_269_5" value="Values" contenteditable="false"/>
<label contenteditable="true">10 : 00 PM</label>
<label id="VoteAnsOP_269_5"></label><br>
<input name="Names" type="radio" class="VoteAns" id="VoteAns_269_6" value="Values" contenteditable="false"/>
<label contenteditable="true">11 : 00 PM</label>
<label id="VoteAnsOP_269_6"></label><br>
</div>
this is js这是js
/*
$jq("input[name=Names]:radio").on('change', function(){
console.log("dfdfd");
});
$jq("input[name=Names]:radio").click(function(){
console.log("dfdfd");
});
console.log($jq("#VoteAns_268_1").val());
$jq('.VoteAns').change(function (){
console.log("vote Answers");
});
*/
/* $jq("input[name=Names]:radio").change(function () {
conosle.log("radiobutton changes");
})*/
/* $jq(".VoteAns").change(function(){
conosle.log("VoteAns");
});*/
/*$jq(".VoteAns").on('change',function(){
conosle.log("VoteAns");
});
$jq("#VoteAns_269_1_lbl").on('change',function(){
conosle.log("VoteAns123");
});*/
/*$jq(".VoteAns").click(function(){
alert("kk");
})*/
$jq("input:radio[name='Names']").change(function(){
alert("input11!!");
});
As u can see in comments I have tried all these code but none of this working form me .正如你在评论中看到的那样,我已经尝试了所有这些代码,但这些代码都没有形成我。 tired of searching and trying different codes whats the problem please help.
厌倦了搜索和尝试不同的代码是什么问题请帮忙。
I want to display specific html on different radio option click我想在不同的单选选项上显示特定的 html 单击
You have incorrect syntax.您的语法不正确。 you have not closes the square bracket while using attribute equals selector:
使用属性等于选择器时,您没有关闭方括号:
$("input:radio[name='Names']").change(function(){
alert("input11!!");
});
HTML HTML
<input type="radio" name="greeting" id="hi" checked="checked" value="hi">hi
<input type="radio" name="greeting" id="hello" value="hello">hello
JS JS
$(document).ready(function () {
$('input:radio[name=greeting]').change(function () {
if (this.value == 'hi') {
alert("hi");
} else if (this.value == 'hello') {
alert("hello");
}
});
});
in your code, you are missing a ]
.That is, your new code would be like在您的代码中,您缺少一个
]
。也就是说,您的新代码将类似于
$("input:radio[name='Names']").click(function(){
alert("input!!");
});
Try this it works for me.试试这个它对我有用。
$("input[name='Names']:radio").change(function () {
alert('input!!');
});
if you are using $jq then make sure that u have that line on top.如果您使用的是 $jq,请确保您在顶部有该行。
$jq = jQuery.noConflict();
$jq("input[name='Names']:radio").change(function () {
alert('input!!');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.