문제

Let I've the <a href="/link/"> tag. How can I the following handle: When the CTRL key is pressed we're left clicked to the <a href="/link/"> tag I want to run an appropriate function which I'll specified as handler of this event. How to do that? I want to do this with pure JS.

도움이 되었습니까?

해결책

<a href="#test" onclick="if(event.ctrlKey) alert('test');">test</a>

다른 팁

I can also recommened the Jquery way.

$('#element').click(function(e)
    {
        if (e.ctrlKey)
        {
            do_something();
        }
    });

May be seems a bit less simple, but I guess it gives you more options aswell.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top