使用javascript添加样式链接按钮时为什么鼠标在css上不起作用? [英] why mouse over css not work when add style to link button using javascript ?

查看:84
本文介绍了使用javascript添加样式链接按钮时为什么鼠标在css上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

i在链接按钮中有一个问题,我有5个链接按钮,如果我们1'st链接按钮点击该链接按钮字体颜色变为蓝色和其他更改为黑色。如果我们点击第二个链接按钮,第二个更改为蓝色,第一个和其他链接按钮字体颜色更改为黑色等等。



通过页面加载所有链接按钮字体颜色为黑色。下面是html代码中的属性更改。

Hai
i have a problem in mover over in link button,i have 5 link buttons one by one,if we 1'st link button is click that link button font color change to blue and other change to black color.if we click 2nd link button ,2nd one change to blue color and 1st and other link button font color change to black color and so on.

By page load all link button font color is black.Below is properties change in html code.

<asp:LinkButton ID="lnkAddDept" runat="server"  Font-Underline="False" CssClass ="change" OnClientClick="return AddDept_ClientClick()"font-family="Arial"
  font-size=" 12px"
  font-weight" bold"
  color=" black">Add Department </asp:LinkButton>







in change css




in change css

.change:hover
      {
          color: Red;
          text-decoration:underline;
        cursor :pointer ;
      }







和每个链接按钮ClientClick事件




and in every link button ClientClick event

document.getElementById("ctl00_ContentPlaceHolder1_lnkAddDept").style.color = "black"
           document.getElementById("ctl00_ContentPlaceHolder1_lnkAddUser").style.color = "black"
           document.getElementById("ctl00_ContentPlaceHolder1_lnkImpADUser").style.color = "black"
           document.getElementById("ctl00_ContentPlaceHolder1_lnkImpUserList").style.color = "black"
           document.getElementById("ctl00_ContentPlaceHolder1_lnkExpUserList").style.color = "#0064a5"







如果我使用上面的javascript更改颜色的链接按钮,之后鼠标在css上工作,但如果我删除javascript然后它将工作,



但我需要的是点击任何一个更改为蓝色的链接,其他人需要更改黑色,还需要将鼠标移到css上









用简单的话说我试着说,如果我改变了fon链接按钮的颜色和尝试在css上使用mouser,它不起作用,但我保留链接按钮的默认属性,鼠标在css工作,



问候

Aravind




if i using above javascript for change color for link button,after that mouse over css not work,but if i remove javascript then it will work,

But my need is if click any link that one change to blue color others need to change black color and also need to work mouse over css




In simple words what i try to say,if i changed font color for link button and try to use mouser over css,it not work,but i leave default property for link button ,mouse over css work,

Regards
Aravind

推荐答案

首先检查你的
AddDept_ClientClick()

方法是否正常工作使用 alert('test')。如果它正常工作,那么更改

method is working properly by using alert('test').If it's working then change your

getElementById

如下所示。首先只测试一个链接(删除javascript函数中的所有其他链接详细信息)





is as below. Firstly just test for one link (remove all other links details inside the javascript function)


document.getElementById("lnkAddDept").style.color = "black"


这篇关于使用javascript添加样式链接按钮时为什么鼠标在css上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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