欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實現(xiàn)動態(tài)生成表格并為行綁定單擊變色動作的方法

 更新時間:2017年04月17日 08:57:03   作者:捂汗縣長  
這篇文章主要介紹了jQuery實現(xiàn)動態(tài)生成表格并為行綁定單擊變色動作的方法,涉及jQuery頁面元素遍歷與事件動態(tài)響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了jQuery實現(xiàn)動態(tài)生成表格并為行綁定單擊變色動作的方法。分享給大家供大家參考,具體如下:

<html>
<head>
<meta charset="utf-8">
<title>jquery表格單擊變色</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function(){
/////////////////以下動態(tài)生成10行2列的表格
for(i=1;i<=10;i++)
{
$("#mytable").append("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>"); 
}
/////////////表格生成結(jié)束
/////////////為生成的行添加單擊變色動作
$("#mytable tr").click(function(){
if($(this).hasClass("redcss"))
{
$(this).siblings("tr").removeClass("redcss");
}
else
{
$(this).addClass("redcss");
$(this).siblings("tr").removeClass("redcss");
}
})
})
</script>
<style>
.redcss{
background-color:#900;
}
</style>
</head>
<body>
<table width="200" border="1" id="mytable"></table>
</table>
</body>
</html>

運行效果如下:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery表格(table)操作技巧匯總》、《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論