会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 128778个问题
WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 61楼
WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 63楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-1.9.1.min%5B1%5D.js"></script>
    <style>
        div{
            width: 100px;
            height: 100px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
<div class="div1"></div>
<br/>
<div class="div2"></div>
<br/>
<div class="div3"></div>
<script>
    /*
    * css()方法
    * 描述:本方法是jq对象读写css样式的方法,相当于js中的style属性
    * 语法:jq对象.css("key","value");
    * 注意:
    * 1.第一个参数是必要的,第二个参数是可选的
    * 2.如果只有一个参数则代表读取属性的值,*/
    $('.div1').click(function () {
        $(this).css({
            "width": "200px",
            "height": "150px",
            "border": "2px solid green",
            "background-color": "aqua"
        })
    })
    $('.div2').click(function () {
        $(this).css({"width":"+=50px"})
    })
    var arrColor=['red','orange','blue','green','purple','gray','pink','black'];
    for (var i = 0;i<arrColor.length;i++){
        $('.div3').click(function () {
            $(this).css({"background-color":"arrColor[i]"})
        })
    }
</script>
</body>
</html>

怎么实现点一下背景颜色就换一次呢,试了好几次都不对。

WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 64楼
WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 67楼
WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 68楼
WEB前端全系列/第三阶段:jQuery编程模块/jQuery基础知识(旧) 69楼

百战程序员微信公众号

百战程序员微信小程序

©2014-2024 百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637