-2

I have something like this:

$(".BWTabVerticalTitle").on("click", function () { alert('You pressed enter!'); });

and something like this:

        $(".BWTabVerticalTitle").keypress(function (e) {
            if (e.which == 13) {
                alert('You pressed enter!');
            }
        });

Now, I would like to combine these 2, to one statement which calls that function. May be something like this:

        $(".BWTabVerticalTitle").on("click", function (e) {
        if (e.which == 13) {
            alert('You pressed enter!');
        }
        }).keypress();

The goal is to activate the function whith the ENTER-key and a click event, but my idea does not work...

Thanks...

0

1 Answer 1

2
 $(".BWTabVerticalTitle").bind('click keydown', function(e) {
     if (e.which === 13) {
        alert('enter!')
     }
     else { alert('click') }
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.