<script type="text/javascript">
$(document).ready(function(){ $("#hide").click(function(){ $("#addfav").hide(1000); });
$("#show").click(function(){ $("#addfav").show(1000); });});</script>
<button id="show" type="button">显示</button>
<button id="show" type="button">显示</button>
我的页面是数据库循环输出,有很多这样的按钮。可是只有第一个有效。
请问怎样让每个按钮都有效。谢谢。
可以使用jquery里面的事件代理
各个版本的写法不同参考链接 https://api.jquery.com/live/