zoukankan      html  css  js  c++  java
  • JS动态,有选择性的改变div颜色

    JS代码:

    <script language="javascript">
    function check(value)
    {
    document.getElementById(value).style.background= "black";
    }
    </script>

    div处部分代码:

    <div id="1" style=" color:#FFF; 40px; height:40px; float:left; margin-right:10px; text-align:center;line-height:40px;">1</div>
    <div id="2" style=" color:#FFF; 40px; height:40px; float:left; margin-right:10px; text-align:center;line-height:40px;">2</div>
    <div id="3" style=" color:#FFF; 40px; height:40px; float:left; margin-right:10px; text-align:center;line-height:40px;">3</div>
    <div id="4" style=" color:#FFF; 40px; height:40px; float:left; margin-right:10px; text-align:center;line-height:40px;">4</div>
    <div id="5" style=" color:#FFF; 40px; height:40px; float:left; margin-right:10px; text-align:center;line-height:40px;">5</div>

    radio处部分代码,使用onclick()函数调用check(),并加入参数,使得与参数相应的div颜色改变:

    <div class="col-lg-12">
    <p class="question-content">
    <input type="radio" name="optionsRadios1" id="optionsRadios1" value="option1" onclick="check(1);">
    A. 220( m{V})、10( m{A}) 
    </p>
    </div>

  • 相关阅读:
    [C++]仿java.lang.String的字符串工具类[原]
    SQL基础1创建表、用户
    Linux中gdb 查看core堆栈信息
    Direct3D9基础工具类[原]
    eclipse3.4启动错误
    ndk连接第三方库
    数据库基本概念
    MySQL常见命令
    MySQL启动和停止
    MySQL配置文件
  • 原文地址:https://www.cnblogs.com/ericren/p/4394327.html
Copyright © 2011-2022 走看看