第一次的jQuery以熟悉jQuery寫法和簡單的事件(click,toggle)

確保jQuery有載入到網頁

$(document).ready(function() {

});

熟悉語法

$(document).ready(function() {
    $('h1').hide(); //將h1隱藏
    $('h1').show(); //將h1顯示
    $(".title").hide(); //將class名稱為title隱藏
    $("h3 .header").hide(); //將h3裡的header隱藏
});

click()事件演練

$(document).ready(function() {
    $(".button").click(function() {
        $("h1").hide();
    }); //點選按鈕將h1隱藏
});


toggle()事件演練

toggle()判斷現在為顯示或隱藏,若為顯示,則點選按鈕將h1隱藏,反之

$(document).ready(function() {
    $(".button").click(function() {
        $("h1").toggle();
    }); 
});

jQuery字典:oscarotero.com/jquery/

#jquery #前端







你可能感興趣的文章

【CSS】- Box Modal(盒模型)

【CSS】- Box Modal(盒模型)

筆記:深入探討 JavaScript 中的參數傳遞:call by value 還是 reference?

筆記:深入探討 JavaScript 中的參數傳遞:call by value 還是 reference?

ES6 的 export 與 import

ES6 的 export 與 import






留言討論