- 主题:jQuery关于radio的一问
if($(input[name=myRadioName]:checked).val()=="1")这种使用方法有错么?
为什么老是报错说expected identifier, string啥的?
google了半天,也尝试了加入<form id....>,然后又写成
if($(#formName input[name=myRadioName]:checked).val()=="1")之类的也还是不行。
不知道到底问题出在哪里。。。
求指点迷津。
--
FROM 180.58.221.*
不好意思,自己敲漏了,实际代码中是敲了引号的。
if($('input[name=myRadioName]:checked').val()=='1')
{...}
还是出现"Expected identifier, string or number"的错误。。。
:(
【 在 zxdong262 的大作中提到: 】
: $('input[name=myRadioName]:checked')
--
FROM 192.55.54.*
把代码精简出来了,还是出错。求高手指点:
<HTML>部分:
<input id="crossRd1" name="crossRd" type="radio" value="1" />xxx
<input id="crossRd2" name="crossRd" type="radio" value="2" checked="checked" />yyy
<input id="crossRd3" name="crossRd" type="radio" value="3" />zzz
<input id="crossRd4" name="crossRd" type="radio" value="4" />www
<script>部分:
<script type="text/javascript">
$(document).ready(function(){
$("input[name=crossRd]").click({
if($('input[name=crossRd]:checked').val()=='1'){
alert("hi");}
});
});
</script>
【 在 cowell 的大作中提到: 】
: 不好意思,自己敲漏了,实际代码中是敲了引号的。
: if($('input[name=myRadioName]:checked').val()=='1')
: {...}
: ...................
--
FROM 192.55.54.*
多谢。我也刚查出这个问题……
汗,javascript的检错能力太弱了,浪费好多时间
:(
【 在 Daughtry 的大作中提到: 】
: .click(function(){...});
--
FROM 192.55.55.*