jQuery实现html表格动态添加新行的方法

jQuery实现动态添加行的方法

<script src="jquery-1.6.2.min.js"></script>

<script type="text/javascript">

<!-- jQuery Code will go underneath this -->

$(document).ready(function () {

jquery$动态,jquery动态绑定事件的方法

// Code between here will only run when the document is ready

$("a[name=addRow]").click(function() {

// Code between here will only run

//when the a link is clicked and has a name of addRow

$("table#myTable tr:last").after('<tr><td>Row 4</td></tr>');

return false;

});

});

</script>

</head>

<body>

<table id="myTable">

<tr><td>Row 1</td></tr>

<tr><td>Row 2</td></tr>

<tr><td>Row 3</td></tr>

</table>

<a href="#" name="addRow">Add Row</a>

</body>

</html>

js或者jquery动态更改a标签的link、hover、visited、active不同的变换,所有值可以手动输入。该怎么设置

代码示例:

$(document).ready(function(){

$("#ceshia").mouseover(function(){

var underline=$("#underline").val();

if(underline==1 ||underline==2) {

var xia="underline";

}

else {

var xia="none";

}

var hover=$("#hover").val();

$("#ceshia:hover").css({

"color":hover,"text-decoration":xia

}

);

}

);

$("#ceshia").mouseout(function(){

var underline=$("#underline").val();

if(underline==0 ||underline==2) {

var xia="none";

}

else {

var xia="underline";

}

var links=$("#link").val();

$("#ceshia:link").css({

"color":links,"text-decoration":xia

}

);

}

);

$("#ceshia").mousedown(function(){

var underline=$("#underline").val();

if(underline==0 ||underline==2) {

var xia="none";

}

else {

var xia="underline";

}

var active=$("#visited").val();

$("#ceshia:active").css({

"color":active,"text-decoration":xia

}

);

}

);

}

);