Skip to content

Instantly share code, notes, and snippets.

@zhenchuan
Created September 21, 2017 23:50
Show Gist options
  • Save zhenchuan/a830010b90a1fc232705cbd55701319a to your computer and use it in GitHub Desktop.
Save zhenchuan/a830010b90a1fc232705cbd55701319a to your computer and use it in GitHub Desktop.
jquery prop vs attr
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="application/javascript" src="jquery.js"></script>
<style>
.table-bordered > thead > tr > th,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > tbody > tr > td,
.table-bordered > tfoot > tr > td {
border: 1px solid #dddddd;
}
.table-bordered > thead > tr > th,
.table-bordered > thead > tr > td {
border-bottom-width: 2px;
}
</style>
</head>
<body>
<table class="table table-striped table-bordered table-hover" id="my-table">
<tr>
<td>
<label>
<input type="radio" name="productRefId" value="1" />
</label>
</td>
<td>
1000010
</td>
<td class="lzc-rt-label">
南河沿大街1号翠明庄宾馆B1层
</td>
</tr>
<tr>
<td>
<label>
<input type="radio" name="productRefId" value="2" />
</label>
</td>
<td>
1000011
</td>
<td class="lzc-rt-label">
王府井银泰in88五层(王府井教堂)
</td>
</tr>
</table>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$("#my-table tr").click(function(e) {
var radio = $(this).find(':radio') ;
radio.prop('checked', true); // attr 就不行
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment