zoukankan      html  css  js  c++  java
  • JavaScript函数传参

    函数传参一:

    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style type="text/css">
        #div1 {
            width: 100px;
            height: 100px;
            background:red;
        }
    </style>
    <script>
        function setcolor(color)
        {
            var odiv=document.getElementById('div1');
            odiv.style.background=color;
        }
    </script>
    </head>
    
    <body id="div1">
    <input type="button" value="黄色" onClick="setcolor('yellow')" />
    <input type="button" value="绿色" onClick="setcolor('green')" />
    </body>
    </html>

     函数传参二:

    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style type="text/css">
        #div1 {
            width: 100px;
            height: 100px;
            background: red;
        }
    </style>
    <script>
        function setstyle(a,b)
        {
            var odiv=document.getElementById('div1');
            odiv.style[a]=b;
        }
    </script>
    </head>
    
    <body>
    <input type="button" value="变宽" onClick="setstyle('width','300px')" />
    <input type="button" value="变高" onClick="setstyle('height','300px')" />
    <input type="button" value="变色" onClick="setstyle('background','green')" />
    <div id="div1"></div>
    </body>
    </html>
  • 相关阅读:
    idea的svn安装
    工作面板视图
    maven的profile
    web 对接 platform
    jdk动态代理在idea的debug模式下不断刷新tostring方法
    jdk动态代理
    springboot获得应用上下文
    数据库时间日期区别
    Java的date和string互转
    httpclient中文乱码
  • 原文地址:https://www.cnblogs.com/xinlvtian/p/7874598.html
Copyright © 2011-2022 走看看