jquery-常用方法

// $(document).ready(fucntion(){....})   可以简写成 $(function(){...})

//常用选择器
// id 选择器  元素  类选择器

//常用方法
// 操作样式,操作内容,操作属性
//css text html attr val

//常用事件
//点击事件 鼠标悬浮   鼠标离开


$(function () {
    //id 选择器
    $('#btn').css({'backgroundColor':'red'});
   //元素选择器
    $('li').text('ceshi');
    // 类选择器
    $('.box').css({'backgroundColor':'red','height':'200px','width':'200px'});

    console.log($('li').text());
    console.log($('li').css('color'));
    console.log($('li').html());
    console.log($('li').attr('src'));

    //点击事件
    $('#btn').click(function () {
        $(this).hide();
    });
    // 鼠标悬浮
    $('#btn').mouseover(function () {
        $(this).css("background-color","yellow");
    });
    // 鼠标离开
    $('#btn').mouseout(function () {
        $(this).css("background-color","blue");
    });
});
原文地址:https://www.cnblogs.com/zy09/p/15190495.html