点击文字选中radio
<html>
<body>
<form action="" name="form1" method="post">
<br />
<label style="cursor:pointer" for="man">
<input type="radio" value="http://fanjf.iteye.com/blog/男" name="man" id="man"/>男
</label>
<label style="cursor:pointer" for="man2">
<input type="radio" value="http://fanjf.iteye.com/blog/女" name="man" id="man2"/>女
</label>
</form>
<input type="radio" id="male" name="sex" checked="checked"/><label style="cursor:pointer" for="male">男1</label>
<input type="radio" id="female" name="sex" /><label style="cursor:pointer" for="female">女1</label>
</body>
</html>
有ID的可以用以上方法,如果没有id呢,那只能自己写js了,一下方法仅供参考
$(".isplist").click(function(){
//alert($(this).val());
$(this).find("input[type=radio]").attr("checked", 'checked');
});
<div name="isp" class="isplist"><input type="radio" name="ispname" value="1"> 联通 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="2"> 电信 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="3"> 移动 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="4"> 铁通 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="5"> 长城 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="6"> 广电 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="7"> 教育网 </div>
<div name="isp" class="isplist"><input type="radio" name="ispname" value="8"> 其它 </div>
window.onload = function () {
//点击radio后面的文本选中radio
// labels = document.getElementById('scalul').getElementsByTagName('span');
// for (i = 0, j = labels.length; i < j; i++) {
// labels[i].onclick = function () {
// var vastr = $(this).parents("li").find("input").val();
// $(this).parents("li").find("input[type=radio][value=" + vastr + "]").attr("checked", 'checked');
// }
// }
//点击整个li选中其里面的radio
labelsa = $(".scalul .li").find("li");
for (i = 0, j = labelsa.length; i < j; i++) {
labelsa[i].onclick = function () {
var vastra = $(this).find("input").val();
$(this).parents("li").find("input[type=radio][value=" + vastra + "]").attr("checked", 'checked');
}
}
}
点击文字选中radio的更多相关文章
- 点击文字选中checkbox
<html> <head> <title>test</title> <meta http-equiv="content-Type&quo ...
- element Cascader 多选 点击文字选中
html 部分 1 <el-form-item label="A部署位置" > 2 <el-cascader 3 v-model="itemType.a ...
- 点击文字可以选中相应的checkbox
<html><head><title>中国站长天空-网页特效-表单特效-点击文字选中的复选框</title><meta http-equiv=&q ...
- zTree -- jQuery 树插件实现点击文字展开子节点
新版本的zTree是单击+号展开子项,点击文字选中该项,双击文字展开子项 项目用的是3.5版本的,如果要点击文字展开子项暂时没查到资料,自己琢磨了下 项目用的是jquery.ztree.core-3. ...
- ztree点击文字勾选checkbox,radio实现方法
ztree的复选框checkbok,单选框radio是用背景图片来模拟的,所以点击文字即使用label括起checkbox,radio文字一起,点击文字也是无法勾选checkbox. 要想点击ztre ...
- radio点击一下选中,再点击恢复未选状态
radio点击一下选中,再点击恢复未选状态 实现方式1: <input type="radio" id="cat" name="ca ...
- juey点击tr选中里面的radio
//点击一行选中银行卡 $("tr").bind("click",function(){ $("input:radio").attr(&qu ...
- js页面文字选中后分享到新浪微博实现
demo您可以狠狠地点击这里:js文字选中分享到新浪微博demo 方法与代码 选中即分享的功能看上去比较高级,其实实现是相当简单的.其中的会让人头大,一般人也不感兴趣的原理这里就直接跳过.这个js文字 ...
- jquery选中radio或checkbox的正确姿势
jquery选中radio或checkbox的正确姿势 Intro 前几天突然遇到一个问题,没有任何征兆的..,jquery 选中radio button单选框时,一直没有办法选中,后来查了许多资料, ...
随机推荐
- Android 4.0以后正确的获取外部sd卡存储目录
刚解决这个棘手的问题 找了很久,随笔记下. 网上搜索 android 获取外部sd卡存储目录 普遍都是: 1) Environment.getExternalStorageDirectory() 这个 ...
- [leetcode-500-Keyboard Row]
Given a List of words, return the words that can be typed using letters of alphabet on only one row' ...
- 【Android Developers Training】 3. 构建一个简单UI
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...
- 5.Smart使用内置函数或者自定义函数
1.使用内置函数 例如使用date函数 {"Y-m-d"|date:$time}格式{第一个参数|方法:第二个参数:第三个参数}即可转换成 2016-07-19 2.使用resi ...
- 从Android源码的角度分析Binder机制
欢迎访问我的个人博客,原文链接:http://wensibo.top/2017/07/03/Binder/ ,未经允许不得转载! 前言 大家好,好久不见,距离上篇文章已经有35天之久了,因为身体不舒服 ...
- H5仿微信界面教程(一)
前言 先来张图,仿微信界面,界面如下,并不完全一模一样,只能说有些类似,希望大家见谅. 1 用到的知识点 jQuery WeUI 是WeUI的一个jQuery实现版本,除了实现了官方插件之外,它还提供 ...
- React周末特训班
Document #react819_content a { text-decoration: none; color: #ef7b2e; border-bottom: 1px solid #ef7b ...
- MySQl开发和生产环境索引对比
--1.创建索引信息表create table `t_index_update` ( `table_name` varchar(20) COLLATE gbk_bin DEFAULT NULL, ...
- Spring Security4实例(Java config 版) —— Remember-Me
本文源码请看这里 相关文章: Spring Security4实例(Java config版)--ajax登录,自定义验证 Spring Security提供了两种remember-me的实现,一种是 ...
- 【SqlServer系列】子查询
1 概述 1.1 已发布[SqlServer系列]文章 [SqlServer系列]SQLSERVER安装教程 [SqlServer系列]数据库三大范式 [SqlServer系列]表单查询 [Sq ...