elements. $(".test").hide() - hides all elements with class="test". $("#test").hide() - hides the element with id="test".
This is a paragraph.
Click me to hide paragraphs button> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); $(“p”) 選擇 p 元素 $(“.class”) 選擇 class $(“#id”) 選擇 idThis is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $("p").hide(1000); }); }); $(“p”).hide $(“p”).show $(“p”).toggleEnter this paragraph.
$(document).ready(function(){ $("#p1").mouseenter(function(){ alert("You entered p1!"); }); }); $(“p”).click $(“p”).dbclick $(“p”).mouseenter $(“p”).mouseleave $(“p”).mousedown $(“p”).mouseup $(“p”).hover $(“p”).focus $(“p”).blurThis is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $("p").fadeOut(3000); }); }); $(“p”).fadeIn() $(“p”).fadeOut() $(“p”).fadeOut(“slow") $(“p”).fadeOut(3000) $(“p”).fadeToggle()This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $("p").slideUp(); }); }); $(“p”).slideDown() $(“p”).slideUp() $(“p”).slideToggle()This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ alert($(“p”).text()) }); }); $(“p”).text() $(“p”).html() $(“p”).val()This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $(“p”).text(“Hello”) }); }); $(“p”).text(“Hello”) $(“p”).html(“Hello”) $(“p”).val(“Hello”)This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $(“p”).append(“Hello”) }); }); $(“p”).append(“Hello”) $(“p”).prepend(“Hello
”) $(“p”).before(“Hello”) $(“p”).after(“Hello”)This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $(“p”).remove() }); }); $(“p”).remove() $(“p”).empty()This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $(“p”).addClass(“blue”) }); }); $(“p”).addClass(“blue”) $(“p”).removeClass(“blue”)This is a paragraph with little content.
This is another small paragraph.
$(document).ready(function(){ $("button").click(function(){ $(“p”).css(“color”, “blue”) }); }); $(“p”).css(“color”,“blue”)