<script>
$(document).ready(function(){
});css
首先,在頁面頂部添加一行script
元素,而後在下一行寫上結束符。html
瀏覽器會運行script
裏全部的Javascript,包括jQuery。瀏覽器
在你的script
元素裏,添加這段代碼:$(document).ready(function() {
到你的script
中,而後在下一行用});
結束它。app
<script>
$(document).ready(function() {
$("button").addClass("animated");
$(".btn").addClass("shake");
$("#target1").addClass("btn-primary");//首選項
});
</script>spa
$("#target1").css("color", "blue");code
$("button").prop("disabled", true);htm
$("h3").html("<em>jQuery Playground</em>");索引
$("#target4").remove();ip
$("#target4").appendTo("#left-well");rem
$("#target2").clone().appendTo("#right-well");//兩個jQuery方法合在一塊兒使用了?這種叫方法鏈function chaining
把target2
從left-well
複製到right-well
,
$("#left-well").parent().css("background-color", "blue")
$("#left-well").children().css("color", "blue")
$(".target:nth-child(3)").addClass("animated bounce");
//如下代碼顯示如何給jQuery Playground中的每一個井中(left well和right well)的第三個子元素添加bounce類:
$(".target:even").addClass("animated shake"); //偶數
$(".target:odd").addClass("animated shake");//奇數
$("body").addClass("animated fadeOut");//整個body有淡出效果
$("body").addClass("animated hinge");//一左上角爲圓心 順時針晃動 下墜淡出