8.7w+
社区成员
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.11.3.js"></script>
</head>
<body>
<form>
<!-- 获取select的selected值 biuuu.com-->
<select id="selectid"><option value="biuuu_s1">s1</option>
<option value="biuuu_s2">s2</option>
<option value="biuuu_s3">s3</option>
<option value="biuuu_s4">s4</option>
</select>
<input type="button" id="sbuttonid" value="获取selected值" /><span id="sresult"></span><br />
<!-- 获取checkbox的checked值 biuuu.com-->
<input type="checkbox" name="checkboxid" value="biuuu_c1" />c1<input type="checkbox" name="checkboxid" value="biuuu_c2" />c2<input type="checkbox" name="checkboxid" value="biuuu_c3" />c3<input type="checkbox" name="checkboxid" value="biuuu_c4" />c4<input type="button" id="cbuttonid" value="获取checkbox值" /><span id="cresult"></span><br />
<!-- 获取radio的checked值 biuuu.com-->
<input type="radio" name="radioid" value="biuuu_r1" />r1<input type="radio" name="radioid" value="biuuu_r2" />r2<input type="radio" name="radioid" value="biuuu_r3" />r3<input type="button" id="rbuttonid" value="获取radio值" /><span id="rresult"></span><br />
<!-- 获取text的value值 biuuu.com-->
<input type="text" id="textid" value="" /><input type="button" id="tbuttonid" value="获取text值" /><span id="tresult"></span></form>
<script type="text/javascript">
$(document).ready(function(){
$("#sbuttonid").click(function(){//获取select对象
var selectedobj = $("#selectid option:selected");//获取当前selected的值
var selected = selectedobj.get(0).value;$("#sresult").html("结果:"+selected);
});
$("#cbuttonid").click(function(){//获取checkbox对象
var check = '';
var checkedobj = $("checkboxid");//获取当前checked的value值 如果选中多个则循环
//$("[name='checkboxid'][@checked]")
checkedobj.each(function(){var ischeck = this.value;check += ischeck;
});
$("#cresult").html("结果:"+check);
});
$("#rbuttonid").click(function(){//获取radio对象
var radioobj = $("[name='radioid'][@checked]");//获取当前checked的value值
var radio = radioobj.get(0).value;$("#rresult").html("结果:"+radio);
});
$("#tbuttonid").click(function(){//获取text对象
var textobj = $("#textid");//获取当前text的value值
var text = textobj.get(0).value;$("#tresult").html("结果:"+text);
});
});
</script>
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LJ</title>
<script src="jquery-1.6.1.min.js"></script>
</head>
<body>
<form>
<!-- 获取select的selected值 -->
<select id="selectid"><option value="s1">s1</option>
<option value="s2">s2</option>
<option value="s3">s3</option>
<option value="s4">s4</option>
</select>
<input type="button" id="sbuttonid" value="获取selected值" /><span id="sresult"></span><br />
<!-- 获取checkbox的checked值 -->
<input type="checkbox" name="checkboxid" value="c1" />c1<input type="checkbox" name="checkboxid" value="c2" />c2<input type="checkbox" name="checkboxid" value="c3" />c3<input type="checkbox" name="checkboxid" value="c4" />c4<input type="button" id="cbuttonid" value="获取checkbox值" /><span id="cresult"></span><br />
<!-- 获取radio的checked值 -->
<input type="radio" name="radioid" value="r1" />r1<input type="radio" name="radioid" value="r2" />r2<input type="radio" name="radioid" value="r3" />r3<input type="button" id="rbuttonid" value="获取radio值" /><span id="rresult"></span><br />
<!-- 获取text的value值 -->
<input type="text" id="LJtextid" value="" /><input type="button" id="tbuttonid" value="获取text值" /><span id="tresult"></span></form>
<script type="text/javascript">
$(document).ready
(
function()
{
$("#sbuttonid").click
(
function()
{//获取select对象
var selectedobj = $("#selectid option:selected");//获取当前selected的值
var selected = selectedobj.get(0).value;$("#sresult").html("结果:"+selected);
}
);
$("#cbuttonid").click(function(){//获取checkbox对象
var check = '';
var checkedobj = $("[name='checkboxid']:checked");
//var checkedobj = $("checkboxid");
//获取当前checked的value值 如果选中多个则循环
//$("[name='checkboxid'][@checked]")
checkedobj.each(function(){var ischeck = this.value;check += ischeck;
});
$("#cresult").html("结果:"+check);
});
$("#rbuttonid").click(
function(){//获取radio对象
//$("#rbuttonid").click(function(){
//获取radio对象
//var radioobj = $("[name='rbuttonid']:checked");
var radioobj = $("[name='radioid']:checked");
//获取当前checked的value值
var radio = radioobj.get(0).value;$("#rresult").html("结果:"+radio);
});
$("#tbuttonid").click
(
function()
{//获取text对象
var textobj = $("#LJtextid");//获取当前text的value值
var text = textobj.get(0).value;$("#tresult").html("结果:"+text);
}
);
$("#adp").click
(
function()
{
var selectedobj = $("#selectid option:selected");//获取当前selected的值
var check = '';
var checkedobj = $("[name='checkboxid']:checked");
//var checkedobj = $("checkboxid");
//获取当前checked的value值 如果选中多个则循环
//$("[name='checkboxid'][@checked]")
checkedobj.each(function(){var ischeck = this.value;check += ischeck;});
var radioobj = $("[name='radioid']:checked");
//获取当前checked的value值
var radio = radioobj.get(0).value;
var textobj = $("#LJtextid");//获取当前text的value值
var text = textobj.get(0).value;
str=selectedobj.get(0).value+"<br />"+check+"<br />"+radio+"<br />"+text;
$('p').append(str+'<br/>');
}
);
$("#AddTable").click
(
function()
{
var check = '';
var checkedobj = $("[name='checkboxid']:checked");
//var checkedobj = $("checkboxid");
//获取当前checked的value值 如果选中多个则循环
//$("[name='checkboxid'][@checked]")
checkedobj.each(function(){var ischeck = this.value;check += ischeck;});
var radioobj = $("[name='radioid']:checked");
//获取当前checked的value值
var radio = radioobj.get(0).value;
var textobj = $("#LJtextid");//获取当前text的value值
var text = textobj.get(0).value;
var selectedobj = $("#selectid option:selected");
var str1=selectedobj.get(0).value;
var str2=check;
var str3=radio;
var str4=text;
$('table tbody').append('<tr><td>'+str1+'</td></tr>' + '<tr><td>'+str2+'</td></tr>' +'<tr><td>'+str3+'</td></tr>' + '<tr><td>'+str4+'</td></tr>')
}
);
}
);
</script>
<p style="font-size:16px; font-family:'黑体'"></p>
<input type="button" id="adp" value="加上P标签" />
<table width="200" border="1">
<tbody>
</tbody>
</table>
<input type="button" id="AddTable" value="加上表格" />
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LJ</title>
<script src="jquery-1.11.3.js"></script>
</head>
<body>
<form>
<!-- 获取select的selected值 -->
<select id="selectid"><option value="s1">s1</option>
<option value="s2">s2</option>
<option value="s3">s3</option>
<option value="s4">s4</option>
</select>
<input type="button" id="sbuttonid" value="获取selected值" /><span id="sresult"></span><br />
<!-- 获取checkbox的checked值 -->
<input type="checkbox" name="checkboxid" value="c1" />c1<input type="checkbox" name="checkboxid" value="c2" />c2<input type="checkbox" name="checkboxid" value="c3" />c3<input type="checkbox" name="checkboxid" value="c4" />c4<input type="button" id="cbuttonid" value="获取checkbox值" /><span id="cresult"></span><br />
<!-- 获取radio的checked值 -->
<input type="radio" name="radioid" value="biuuu_r1" />r1<input type="radio" name="radioid" value="biuuu_r2" />r2<input type="radio" name="radioid" value="biuuu_r3" />r3<input type="button" id="rbuttonid" value="获取radio值" /><span id="rresult"></span><br />
<!-- 获取text的value值 -->
<input type="text" id="LJtextid" value="" /><input type="button" id="tbuttonid" value="获取text值" /><span id="tresult"></span></form>
<script type="text/javascript">
$(document).ready
(
function()
{
$("#sbuttonid").click(function(){//获取select对象
var selectedobj = $("#selectid option:selected");//获取当前selected的值
var selected = selectedobj.get(0).value;$("#sresult").html("结果:"+selected);
});
$("#cbuttonid").click(function(){//获取checkbox对象
var check = '';
var checkedobj = $("[name='checkboxid']:checked");
//var checkedobj = $("checkboxid");
//获取当前checked的value值 如果选中多个则循环
//$("[name='checkboxid'][@checked]")
checkedobj.each(function(){var ischeck = this.value;check += ischeck;
});
$("#cresult").html("结果:"+check);
});
$("[name='rbuttonid']:checked").click(function(){//获取radio对象
//$("#rbuttonid").click(function(){
//获取radio对象
//var radioobj = $("[name='rbuttonid']:checked");
var radioobj = $("[name='radioid'][@checked]");
//获取当前checked的value值
var radio = radioobj.get(0).value;$("#rresult").html("结果:"+radio);
});
$("#tbuttonid").click
(
function()
{//获取text对象
var textobj = $("#LJtextid");//获取当前text的value值
var text = textobj.get(0).value;$("#tresult").html("结果:"+text);
}
);
$("#adp").click
(
function()
{
var selectedobj = $("#selectid option:selected");//获取当前selected的值
str=selectedobj.get(0).value;
$('p').append(str+'<br/>')
}
);
$("#AddTable").click
(
function()
{
var selectedobj = $("#selectid option:selected");
str=selectedobj.get(0).value;
$('table tbody').append('<tr><td>'+str+'</td></tr>')
}
);
}
);
</script>
<p></p>
<input type="button" id="adp" value="加上P标签" />
<table>
<tbody>
</tbody>
</table>
<input type="button" id="AddTable" value="加上表格" />
</body>
</html>
单选按钮radio无效
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.11.3.js"></script>
</head>
<body>
<form>
<!-- 获取select的selected值 biuuu.com-->
<select id="selectid"><option value="s1">s1</option>
<option value="s2">s2</option>
<option value="s3">s3</option>
<option value="s4">s4</option>
</select>
<input type="button" id="sbuttonid" value="获取selected值" /><span id="sresult"></span><br />
<!-- 获取checkbox的checked值 -->
<input type="checkbox" name="checkboxid" value="c1" />c1<input type="checkbox" name="checkboxid" value="c2" />c2<input type="checkbox" name="checkboxid" value="c3" />c3<input type="checkbox" name="checkboxid" value="c4" />c4<input type="button" id="cbuttonid" value="获取checkbox值" /><span id="cresult"></span><br />
<!-- 获取radio的checked值 biuuu.com-->
<input type="radio" name="radioid" value="biuuu_r1" />r1<input type="radio" name="radioid" value="biuuu_r2" />r2<input type="radio" name="radioid" value="biuuu_r3" />r3<input type="button" id="rbuttonid" value="获取radio值" /><span id="rresult"></span><br />
<!-- 获取text的value值 biuuu.com-->
<input type="text" id="textid" value="" /><input type="button" id="tbuttonid" value="获取text值" /><span id="tresult"></span></form>
<script type="text/javascript">
$(document).ready(function(){
$("#sbuttonid").click(function(){//获取select对象
var selectedobj = $("#selectid option:selected");//获取当前selected的值
var selected = selectedobj.get(0).value;$("#sresult").html("结果:"+selected);
});
$("#cbuttonid").click(function(){//获取checkbox对象
var check = '';
var checkedobj = $("[name='checkboxid']:checked");
//var checkedobj = $("checkboxid");
//获取当前checked的value值 如果选中多个则循环
//$("[name='checkboxid'][@checked]")
checkedobj.each(function(){var ischeck = this.value;check += ischeck;
});
$("#cresult").html("结果:"+check);
});
$("[name='rbuttonid']:checked").click(function(){//获取radio对象
//$("#rbuttonid").click(function(){
//获取radio对象
//var radioobj = $("[name='rbuttonid']:checked");
var radioobj = $("[name='radioid'][@checked]");
//获取当前checked的value值
var radio = radioobj.get(0).value;$("#rresult").html("结果:"+radio);
});
$("#tbuttonid").click(function(){//获取text对象
var textobj = $("#textid");//获取当前text的value值
var text = textobj.get(0).value;$("#tresult").html("结果:"+text);
});
});
</script>
</body>
</html>
单选radio 还是没效果var checkedobj = $("[name='checkboxid']:checked");
$("[name='rbuttonid']:checked").click(function(){//获取radio对象