http://www.skygq.com/2011/01/01/jquery%E5%9F%BA%E6%9C%AC%E7%94%A8%E6%B3%95%E6%80%BB%E7%BB%93/
$("#id").text("hello");
$("#id").html("<strong>hello</strong>");
$("#btn").click(function(){xxx});
$("#btn").click(xxx);
$("#btn").on("click",function(){xx});
<html>
<button id="add">Add new</button>
<div id="container">
<button class="alert">alert!</button>
</div>
</html>
<script>
$("button#add").click(function() {
var html = "<button class='alert'>Alert!</button>";
$("button.alert:last").parent().append(html);
});
</script>
with unbinding via
$("#element").off("click.someNamespace");
$("#whatever").trigger("click");
本文介绍了jQuery的基本使用方法,包括元素的选择与操作、事件绑定与触发等,并通过实例展示了如何利用jQuery动态添加按钮。


被折叠的 条评论
为什么被折叠?



