key pressed, should the function still return false...">

Using jQuery animate (), if the element with the "<a href=" https://stackoverflow.com/# "...> </a> key pressed, should the function still return false?

I read the jQuery page for animate ()

http://api.jquery.com/animate/

Its examples are not mentioned, if used

<a href="#" id="clickme">click me</a>
...

$('#clickme').click(function() {
    $('#someDiv').animate({left: "+=60"});
})

do we still need to return false as in the old days?

$('#clickme').click(function() {
    $('#someDiv').animate({left: "+=60"});
    return false;
})

(but then these examples were not used <a>for "click me" ... but they used something else.

Otherwise, the page will return to the top of the page? Does jQuery have a more elegant or magical way to do this?

+3
source share
1 answer

event.preventDefault():

$('...').click(function(event) {
    event.preventDefault();
    // Code.
});

jQuery Website:

event.preventDefault()
: , .

+3

Source: https://habr.com/ru/post/1750034/


All Articles