报表选中TR,自动勾选CHECKBOX的方法

WBOY
Release: 2016-06-13 11:51:42
Original
933 people have browsed it

表格选中TR,自动勾选CHECKBOX的方法
  大家好,我碰到这样一个问题

  我有一个TABLE,我希望单击这个TABLE的某一行的任意位置,则这个TABLE前面的CHECKBOX能够被选中,并且该行背景颜色改变,反之取消勾选


------解决方案--------------------
给个例子参考吧

 <style><br /> .selected {<br />    background-color: red;<br />}<br /> </style><br /> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script><br /> <script><br /> $(function(){<br /> $('#data tr').on('click', function() {<br />    $(this).toggleClass('selected');<br />	var checkBoxe = $(this).find("input");<br />	checkBoxe.prop("checked", !checkBoxe.prop("checked"));<br />});<br /> });<br /></script><br /><table id='data'><br /><tr><td><input type="checkbox" value="1"></td><td>eeeeeeeeeee</td></tr><br /><tr><td><input type="checkbox" value=""></td><td>fffffffffff</td></tr><br /><tr><td><input type="checkbox" value=""></td><td>ggggggggggg</td></tr><br /></table>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!