有一个div在加载时显示在页面上。我在这个div中添加了一个按钮,我希望当用户点击这个按钮时,它会使用JQuery隐藏div。使用JQuery隐藏div - 不工作
下面是HTML:
<div id="tabs" class="news1">
<ul>
<li><a href="#tabs-1">Track</a></li>
<li><a href="#tabs-2">History</a></li>
</ul>
<div id="tabs-1">
<table id="currentloc_table">
<tr>
<th></th>
<th>Name</th>
<!--th>Latitude</th>
<th>Longitude</th-->
<th>Details</th>
</tr>
<tr><td></td></tr>
</table>
</div>
<div id="tabs-2">
</div>
<button>hide</button>
</div>
这里是同一页上的代码的脚本:
<script>
$(function() {
$("#tabs").tabs();
});
$("button").click(function() {
$(this).parent().hide();
});
</script>
但由于某种原因,这是行不通的。有什么建议么?
谢谢。
确保$(document).ready()中的脚本; – 2013-04-07 18:56:38
它在这里工作http://jsfiddle.net/wQ3nn/ – Sachin 2013-04-07 18:59:31
@Sachin无关。如果你在jsFiddle中使用'onLoad'模式,那么它本质上是一个模拟的'$(document).ready()'。试试[这一个](http://jsfiddle.net/wQ3nn/1/)。 – 2013-04-07 19:00:26