jQuery

01 - Learn how Script Tags and Document Ready Work

  • 先添加 document ready function

  • 若沒有添加 $(document).ready(function() { });, js 會在 html 渲染前就先執行,這樣會產生 bug

<script>
  $(document).ready(function() { });
</script>

<!-- Only change code above this line. -->

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">
      <h4>#left-well</h4>
      <div class="well" id="left-well">
        <button class="btn btn-default target" id="target1">#target1</button>
        <button class="btn btn-default target" id="target2">#target2</button>
        <button class="btn btn-default target" id="target3">#target3</button>
      </div>
    </div>
    <div class="col-xs-6">
      <h4>#right-well</h4>
      <div class="well" id="right-well">
        <button class="btn btn-default target" id="target4">#target4</button>
        <button class="btn btn-default target" id="target5">#target5</button>
        <button class="btn btn-default target" id="target6">#target6</button>
      </div>
    </div>
  </div>
</div>

02 - Target HTML Elements with Selectors Using jQuery

  • $ dollar sign operator, bling

  • 選擇器

  • 添加跳動動畫

  • 已經預載 jQuery.js, animated bounce.css

03-Target Elements by Class Using jQuery

  • 替 div.well 添加 shake 特效

04-Target Elements by ID Using jQuery

  • 替 div#target3 添加 fadeout 特效

05-Delete your jQuery Functions

  • 教學說 jQurey 的特效會讓人分心,要我先把三個語句都刪掉 XD

06-Target the same element with multiple jQuery Selectors

  • 從前面知道了 type: $("button"), class:$(".btn"), id:$("target3") 三種選擇方式

  • 讓一個元素能被 jQuery Selectors 選擇多次

07-Remove classes from an element with jQuery

  • 移除某個元素 or 選擇器的 class

  • 但我根本看不出效果啊 @@

  • 有啦就是 button 從灰色變成白色

08-Change the CSS of an Element Using jQuery

  • 用 jQuery 改變 css

  • 有 quote,用 comma instead of colon

09-Disable an Element Using jQuery

  • 直接用 jQuery 修改除了 css 以外的元素的屬性

  • 例如,讓按鈕不可選

10-Change Text Inside an Element Using jQuery

  • 覆蓋某個元素中的 html 內容

  • .html()

11-Remove an Element Using jQuery

  • 移除某個元素

  • .remove()

12-Use appendTo to Move Elements with jQuery

  • 把 div 中的某個元素,移動到另外一個 div 中

  • appendTo()

13-Clone an Element Using jQuery

  • 複製元素

  • clone()

  • function chaining,方法鏈,串起兩個方法

14-Target the Parent of an Element Using jQuery

  • 每個元素都有父元素

  • 可用 parent() 訪問父元素

15-Target the Children of an Element Using jQuery

  • 訪問該元素底下的所有子元素

  • children()

16-Target a Specific Child of an Element Using jQuery

17-Target Even Numbered Elements Using jQuery

  • 選擇索引為奇數或是偶數的元素

18-Use jQuery to Modify the Entire Page

  • 整個頁面 $("body")

  • fadeout, hinge

Last updated

Was this helpful?