Slide 1

Slide 1 text

JQuery 基礎篇

Slide 2

Slide 2 text

使⽤ JQuery

Slide 3

Slide 3 text

JQuery 起⼿式 $(function(){ // jQuery methods go here... }); $(this).hide() - hides the current element. $("p").hide() - hides all

elements. $(".test").hide() - hides all elements with class="test". $("#test").hide() - hides the element with id="test".

Slide 4

Slide 4 text

選擇器

This is a heading

This is a paragraph.

Click me to hide paragraphs button> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); $(“p”) 選擇 p 元素 $(“.class”) 選擇 class $(“#id”) 選擇 id

Slide 5

Slide 5 text

Hide, Show Hide

This 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”).toggle

Slide 6

Slide 6 text

事件

Enter 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”).blur

Slide 7

Slide 7 text

FadeIn, FadeOut Hide

This 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()

Slide 8

Slide 8 text

Slide Hide

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()

Slide 9

Slide 9 text

Get Hide

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()

Slide 10

Slide 10 text

Set Hide

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”)

Slide 11

Slide 11 text

Add Hide

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”)

Slide 12

Slide 12 text

Remove Hide

This is a paragraph with little content.

This is another small paragraph.

$(document).ready(function(){ $("button").click(function(){ $(“p”).remove() }); }); $(“p”).remove() $(“p”).empty()

Slide 13

Slide 13 text

CSS Class Hide

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”)

Slide 14

Slide 14 text

CSS Hide

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”)

Slide 15

Slide 15 text

數字的平⽅函數呢?

Slide 16

Slide 16 text

Javascript 觸發 現在時間

Hello

Slide 17

Slide 17 text

利⽤ Bootstrap 的 Button ?

Slide 18

Slide 18 text

Javascript String 函數

var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var sln = txt.length; document.getElementById(“demo"). innerHTML = sln 26

Slide 19

Slide 19 text

Javascript Array

var list = [‘A’, ‘B’, ‘C’] document.getElementById(“demo"). innerHTML = list[0] ABC

Slide 20

Slide 20 text

計數器