zoukankan      html  css  js  c++  java
  • 作品第一课----改变DIV样式属性

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
        .btn { margin: 0 auto; padding-left: 30%;}
        .img {  200px; height: 200px; margin: 10% 30%; background-color: #000; }
        
    
        </style>
        <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    </head>
    <body>
        <div class="btn">
            <input type="button" class="be_width" value="变宽">
            <input type="button" class="be_height" value="变高">
            <input type="button" class="be_color" value="变色">
            <input type="button" class="be_hide" value="隐藏">
            <input type="button" class="be_reset" value="重置">
        </div>
    
        <div class="img">
            
        </div>
        <script>
            var width = $(".img").css('width');
            var height = $(".img").css('height');
            var color = $(".img").css('background-color');
            
            var new_width = parseInt(width) + 200 + 'px';
            var new_height = parseInt(height) + 200 + 'px';
            console.log(new_width);
            $(".be_width").on("click", function() {
                $(".img").css("width", new_width);
            });
    
            $(".be_height").on("click", function(){
                $(".img").css("height", new_height);
            });
    
            $(".be_color").on("click", function(){
                $(".img").css("background-color", "red");
            });
    
            $(".be_hide").on("click", function(){
                $(".img").hide();
            });
    
            $(".be_reset").on("click", function(){
                $(".img").show().css({"width": "200px", "height": "200px", "background-color": "#000"});
    
            });
    
    
        </script>
    </body>
    </html>
  • 相关阅读:
    445port入侵具体解释
    重构摘要12_大型重构
    Matlab画图-非常具体,非常全面
    期望DP
    自己实现一个SQL解析引擎
    信息熵(Entropy)究竟是用来衡量什么的?
    速算123,公布
    OCP-1Z0-051-题目解析-第28题
    选择排序
    Android入门第八篇之GridView(九宫图)
  • 原文地址:https://www.cnblogs.com/samtrybest/p/5071436.html
Copyright © 2011-2022 走看看