您的位置:首页 > Web前端 > JQuery

JQuery 多属性选择节点

2016-05-19 20:34 573 查看
JQuery 1.6.0+以后用prop()代替attr();

多属性选择节点

$("input[type=checkbox][name='first2'][value='first4']")。


<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-2.2.3.js"></script>

<script type="text/javascript">
<!--

//-->
function first(){
var checked = $("input[type=checkbox][name='first2'][value='first4']").prop("checked");
if(checked == true){
$("input[type=checkbox][name='first2'][value='first4']").prop("checked", false);
}else{
$("input[type=checkbox][name='first2'][value='first4']").prop("checked", true);
}
}

</script>
</head>
<body>
<input type="checkbox" id="first1" name="first2" title="first3" value="first4"/>
<input type="button" id="button" onclick="first()" value="提交"/>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: