超链接不能够有图像状态,即onmousedown事件 [英] hyperlink not being able to have image states, i.e onmousedown

查看:196
本文介绍了超链接不能够有图像状态,即onmousedown事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个快速的问题...我有一个母版,并有反正我可以瞄准的含量 - 面积,而无需使用超链接?我已经使用按钮和链接按钮尝试,但它从来没有工作过。究其原因,就是因为我想有按钮状态,我不知道如何去这样做。
我已经加入了图像的链接

I have a quick question...I have a masterpage and is there anyway that I can target the contentarea without having to use hyper links? I have tried using buttons and link buttons but it never worked. The reason why is because I want to have button states and I'm not sure how to go about doing this. I have added an image to the link

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Tabbet.aspx"ImageUrl="~/Icons/Icon_english_a.png">HyperLink</asp:HyperLink>

和我的code后面,试图表现出任何状态

and my code behind to try and show any state

void btn()
    {
        HyperLink1.Attributes.Add("onmousedown", "src='Images/logo.png'");
    }

当我点击图像,图像不更改为关闭状态。

when I click on the image, the image is not changing to a down state.

感谢

推荐答案

是的,我有解决方案,你应该尝试下列方式:

yes I have solution you should try following way:

 <script src="Scripts/jquery-1.7.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#<%=Hyperlink1.ClientID%> img").hover(function () {
                $(this).attr("src", "/Images/logo.png");
            }, function () {
                $(this).attr("src", "/Icons/Icon_english_a.png");
            }).mousedown(function () {
                $(this).attr("src", "/Images/logo.png");
            }).mouseup(function () {
                $(this).attr("src", "/Icons/Icon_english_a.png");
            });
        });

    </script>

这篇关于超链接不能够有图像状态,即onmousedown事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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