获取组中选中的单选按钮的值时出现问题
Issue with obtaining the value of the checked radio button in a group?
请看看我的测试页面,我的问题是在"选择图片"组中找到所选单选按钮的值。
加载时,我使用了以下代码:
var currentImageFile = $("input:radio[name=selectedImage]:checked").val();
选取左侧"Selected picture"div的默认图像。到目前为止一切顺利。
现在的问题是,当一个"选择图片"单选按钮随后点击我的事件代码:
$("input:radio[name=selectedImage]").click(function() {
currentImageFile = $(this).val();
alert($(this).val());
});
(警报仅用于测试)根本不返回任何值!
HTML非常直接:
<li><div class="xmasImage rounded" rel="http://www.completeinsight.co/resources/xmasHR/56269.jpg">
<img class="rounded" src="http://www.completeinsight.co/resources/xmasLR/56269_p.jpg" width="65" height="65" border="0" alt="56269" />
<div class="imageSelect"><input type="radio" name="selectedImage" value="56269">
<label for="selectedImage">56269</label>
</div>
</div></li>
我错过了显而易见的?? ?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var currentImageFile = '';
$('#ImageSelection').find("input:radio[name=selectedImage]").click(function () {
currentImageFile = $(this).val();
alert($(this).val());
});
});
</script>
</head>
<body>
<ul id="ImageSelection">
<li>
<div class="xmasImage rounded" rel="http://www.completeinsight.co/resources/xmasHR/56269.jpg">
<img class="rounded" src="http://www.completeinsight.co/resources/xmasLR/56269_p.jpg"
width="65" height="65" border="0" alt="56269" />
<div class="imageSelect">
<input type="radio" name="selectedImage" value="56269">
<label for="selectedImage">56269</label>
</div>
</div>
</li>
<li>
<div class="xmasImage rounded" rel="http://www.completeinsight.co/resources/xmasHR/56270.jpg">
<img class="rounded" src="http://www.completeinsight.co/resources/xmasLR/56270_p.jpg"
width="65" height="65" border="0" alt="56270" />
<div class="imageSelect">
<input type="radio" name="selectedImage" value="56270">
<label for="selectedImage">56270</label>
</div>
</div>
</li>
</ul>
</body>
</html>
相关文章:
- html单选按钮检查问题
- jquery 单选按钮更改问题
- 贝宝表单问题的单选按钮选择
- Javascript测验,有4个问题.单选按钮+继续按钮
- 单选按钮切换按钮问题
- Javascript 单选按钮警报的问题
- 在 Google Apps 脚本中循环访问单选按钮值时遇到问题
- JavaScript 单选按钮问题
- 多项选择测验-单选按钮和功能问题
- jquery动态选择单选按钮(表单重置问题)
- 检索反馈表单的单选按钮值时出现问题
- struts2与jquery单选按钮事件问题
- jquery单选按钮,以及另外两个小问题
- JavaScript 中的 HTML 单选按钮验证问题
- 从显示的问题组中查找选定的单选按钮值
- 如何隐藏单选按钮直到出现问题
- 获取单选按钮值,但存在可变问题
- 使用jQuery根据条件选择/取消选中单选按钮的问题
- 在线测验:通过选择不同的单选按钮将答案和问题分为3类
- 抓取选中单选按钮的问题- JavaScript