html结构:
<td><span id="is_mar431"><input class="is_mar" value="0" id="is_mar431_0" checked="checked" type="radio" name="is_mar431" /> <label for="is_mar431_0">否</label> <input class="is_mar" value="1" id="is_mar431_1" type="radio" name="is_mar431" /> <label for="is_mar431_1">是</label></span></td> js结构(前): // 是否损坏,选择是,显示损坏信息输入文本框 $("span[id^=is_mar] :radio").change( function() { var this_name = $(this).attr("name"); var input_id = 'mar_note_'+this_name.substring(6); if ($("input[name="+this_name+"]:checked").val() == 1) { $("#"+this_name+"").after('<span id="J_'+input_id+'"> 损坏信息:<input id="'+input_id+'" type="text" tabindex="3" name="'+input_id+'" value="" /></span>'); } else { $("#J_"+input_id+"").remove(); } }); js结构(后): // 是否损坏,选择是,显示损坏信息输入文本框 $("span[id^=is_mar] :radio").live("change",function() { var this_name = $(this).attr("name"); var input_id = 'mar_note_'+this_name.substring(6); if ($("input[name="+this_name+"]:checked").val() == 1) { $("#"+this_name+"").after('<span id="J_'+input_id+'"> 损坏信息:<input id="'+input_id+'" type="text" tabindex="3" name="'+input_id+'" value="" /></span>'); } else { $("#J_"+input_id+"").remove(); } }); 参考live的网址:http://www.w3school.com.cn/jquery/event_live.asp
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/175109.html