您当前的位置: 首页 >  jquery

壹小俊

暂无认证

  • 0浏览

    0关注

    885博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Jquery第三课--jquery与HTML的配合

壹小俊 发布时间:2019-09-17 21:54:51 ,浏览量:0

a.获得内容 - text()、html() 以及 val() b.获取属性 - attr() c. append() - 在被选元素的结尾插入内容 prepend() - 在被选元素的开头插入内容 after() - 在被选元素之后插入内容 before() - 在被选元素之前插入内容 d. remove() - 删除被选元素(及其子元素) empty() - 从被选元素中删除子元素 e. addClass() - 向被选元素添加一个或多个类 removeClass() - 从被选元素删除一个或多个类 toggleClass() - 对被选元素进行添加/删除类的切换操作 css() - 设置或返回样式属性




    
    
    
    Document
    
    .button{
        width: 100px;
        height: 100px;
        background-color: aquamarine
    }
    


    click me!




$(function () { 
    $('button').click(function () { 
        // $(this).addClass('button')
        // $(this).removeClass('button')
        // $(this).toggleClass('button')
        $(this).css('color','blue')
     })
    // $('button').click(function () { 
    //     console.log($('input').val())
    //     console.log($('p').html())
    //     console.log($('span').attr('where'))
    //     $('input').val('456')
    //     $('p').html('word')
    //     $('span').attr('where','2')
    //     $('span').append('

你好

') // $('p').prepend('

abc!

') // $('span').after('123
关注
打赏
1664335782
查看更多评论
0.0390s