可能重复:
A small modification needed in html script using javascript, i m not able to sort out当我点击“其他”单选按钮时没有任何反应。为什么?
HTML:
<div class="rButtons">
<input type="radio" name="numbers" value="10" onclick="uncheck();" />10
<input type="radio" name="numbers" value="20" onclick="uncheck();" />20
<input type="radio" name="numbers" value="other" onchange="blahblahblah();"/>other
<input type="text" id="other_field" name="other_field" onblur="checktext(this);"/>
</div>
CSS:
<style type="text/css">
#other_field{
visibility: hidden;
width:40px;
height:14px;
border:1px solid #777;
background-color:#111;
font-size:10px;
color:#666;
}
</style>
的jQuery:
<script>
function blahblahblah()
{
var $radios = $('input:radio[name=numbers]');
if ($radios.is(':checked') === true) {
$("#other_field").show();
}
else
{
$("#other_field").hide();
}
}
</script>
一切都很好..但问题是这个..当我点击“其他”单选按钮什么也没有发生..而它应该是打开其他领域。
请勿使用内联事件!你正在使用jQuery,利用它来添加事件! – epascarello