html中的单选按钮:
<input type='radio' name='sample' id='dynamic' value=dynamic required='true'>
单选按钮的jquery函数:
$(document).ready(function() {
$("input:radio").on("click", function()
{
alert('hieeee');
});
});
它没有正常工作 我也尝试过以下代码
$('input:radio[name="sample"]').change(function(){
if ($(this).is(':checked'))
{
alert('hieee');
}
});
但这些功能对我不起作用
答案 0 :(得分:0)
试试这个
$('input:radio[name="postage"]').change(
function(){
if ($(this).is(':checked') && $(this).val() == 'Yes') {
// append goes here
}
});
Or, the above - again - using a little less superfluous jQuery:
$('input:radio[name="postage"]').change(
function(){
if (this.checked && this.value == 'Yes') {
// note that, as per comments, the 'changed'
// <input> will *always* be checked, as the change
// event only fires on checking an <input>, not
// on un-checking it.
// append goes here
}
});