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>
  • 相关阅读:
    关于垂直居中
    linux 前后台程序切换
    mac 下jetbrains IDE系列IDE主题
    mac 安装命令行开发者工具
    python 安装MySQLdb mysql_config not fount
    error: command 'cc' failed with exit status 1
    sqllite 入门
    jieba分词
    zookeeper 故障重连机制
    深入学习 celery
  • 原文地址:https://www.cnblogs.com/samtrybest/p/5071436.html
Copyright © 2011-2022 走看看