互斥的div元素 [英] mutually exclusive div element

查看:389
本文介绍了互斥的div元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个div元素如下。

i想让它们互相排斥......比如当我点击高优先级div时,低优先级背景颜色应该改变,反之亦然。



i have a two div elements as follows.
i want to make them mutually exclusive...like when i click on high priority div,low priority background color should change and vice versa.

<table>
        <tr>
            <td>
                <div id="divHighPriority"  önclick="high();">
                    <asp:Label runat="server" ID="lblHighPriority" Text="High Priority"></asp:Label>
                    <asp:ImageButton ImageUrl="../Images/High.JPG" runat="server" ID="imgBtnHigh" ToolTip="High Priority" />
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="divLowPriority"  önclick="low();">
                    <asp:Label runat="server" ID="lblLowPriority" Text="Low Priority"></asp:Label>
                    <asp:ImageButton ImageUrl="../Images/Low.jpg" runat="server" ID="imgBtnLow" ToolTip="Low Priority" />
                </div>
            </td>
        </tr>
    </table>

推荐答案

尝试如下。

Try like below.
function high()
{
    var lowDiv = document.getElementById("divLowPriority");
    lowDiv.style.backgroundColor = '#FFFFFF'; // assign any color.
}

function low()
{
    var highDiv = document.getElementById("divHighPriority");
    highDiv.style.backgroundColor = '#FFFFFF'; // assign any color.
}


这篇关于互斥的div元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆