- hides the current element. $("p").hide() - hides all <p> elements. $(".test").hide() - hides all elements with class="test". $("#test").hide() - hides the element with id="test".
me to hide paragraphs</ button> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); $(“p”) 選擇 p 元素 $(“.class”) 選擇 class $(“#id”) 選擇 id
<p>This is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $("p").hide(1000); }); }); $(“p”).hide $(“p”).show $(“p”).toggle
<p>This is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $("p").fadeOut(3000); }); }); $(“p”).fadeIn() $(“p”).fadeOut() $(“p”).fadeOut(“slow") $(“p”).fadeOut(3000) $(“p”).fadeToggle()
is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $("p").slideUp(); }); }); $(“p”).slideDown() $(“p”).slideUp() $(“p”).slideToggle()
is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ alert($(“p”).text()) }); }); $(“p”).text() $(“p”).html() $(“p”).val()
is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $(“p”).text(“Hello”) }); }); $(“p”).text(“Hello”) $(“p”).html(“Hello”) $(“p”).val(“Hello”)
is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $(“p”).append(“Hello”) }); }); $(“p”).append(“Hello”) $(“p”).prepend(“ <p>Hello</p> ”) $(“p”).before(“Hello”) $(“p”).after(“Hello”)
<p>This is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $(“p”).addClass(“blue”) }); }); $(“p”).addClass(“blue”) $(“p”).removeClass(“blue”)
is another small paragraph.</p> $(document).ready(function(){ $("button").click(function(){ $(“p”).css(“color”, “blue”) }); }); $(“p”).css(“color”,“blue”)