jQuery--FreeCodeCamp

  1. first add a script
<script>
  $(document).ready(function() {

  });
</script>
  1. . All jQuery functions start with a $ , usually referred to as a dollar sign operator, or as bling.
  2. jQuery often selects an HTML element with a selector , then does something to that element.
// included both the jQuery library and the Animate.css library
<script>
  $(document).ready(function() {
// jQuery's .addClass() function, which allows you to add classes to elements.
//
//aimed at HTML element
    $("button").addClass("animated bounce");
    $("button").removeClass("btn-default");
//aimed at clsss
    $(".well").addClass("animated shake");
//aimed at ID
$("#target3").addClass("animated fadeOut");
  });
</script>
  1. change CSS
    jQuery has a function called .css() that allows you to change the CSS of an element.
$("#target1").css("color", "blue");
  1. Disable an element(cant click on it)
$("button").prop("disabled", true);
  1. Change Text Inside an Element
    $("#target4").html("<em>#target4</em>");
  1. remove element
    $("#target4").remove();
  1. move element by function called appendTo
$("#target2").appendTo("#right-well");
  1. clone an element
$("#target5").clone().appendTo("#left-well");
  1. target the parent/children of element
 $("#target1").parent().css("background-color", "red");
$("#right-well").children().css("color", "orange")
//target on specific child--the second child here
$(".target:nth-child(2)").addClass("animated bounce");
//all odd target
$(".target:odd").addClass("animated shake");
  1. can also target on <body>
  1. sum up
element.addClass
element.removeClass
element.css
element.prop
element.remove
element.appendTo

Some new WORDS:

distracting adj. 分心的;分散注意力的

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容