Hello everyone~ I saw the following code when I was studying a website
This part of the code corresponds to the picture below. The character part in the picture is the link
When I clicked on the character in the picture, the website happened Jump (you can see that the URL has not changed)
What I don’t understand is how the jump is achieved? Or how to achieve this action?
And in the tag here, what does href="" mean? Does the tag have the data-page attribute?
Custom attributes, event control page display is added to the a tag
Custom attributes, event control page display is added on the a tag
Custom attributes, event control page display is added to the a tag
<!DOCTYPE html><html><head><script src="/jquery/jquery-1.11.1.min.js"></script></head><body><a data-a="a">aaaaaaaaaa</a><a data-a="a1">aaaaaaaaaa</a><a data-a="a2">aaaaaaaaaa</a><a data-a="a3">aaaaaaaaaa</a><script>$('a[data-a]').click(function(){alert($(this).attr('data-a'))})</script></body></html>
Custom attributes, event control page display is added to the a tag
<!DOCTYPE html><html><head><script src="/jquery/jquery-1.11.1.min.js"></script></head><body><a data-a="a">aaaaaaaaaa</a><a data-a="a1">aaaaaaaaaa</a><a data-a="a2">aaaaaaaaaa</a><a data-a="a3">aaaaaaaaaa</a><script>$('a[data-a]').click(function(){alert($(this).attr('data-a'))})</script></body></html>
Custom attributes, event control page display is added to the a tag
<!DOCTYPE html><html><head><script src="/jquery/jquery-1.11.1.min.js"></script></head><body><a data-a="a">aaaaaaaaaa</a><a data-a="a1">aaaaaaaaaa</a><a data-a="a2">aaaaaaaaaa</a><a data-a="a3">aaaaaaaaaa</a><script>$('a[data-a]').click(function(){alert($(this).attr('data-a'))})</script></body></html>
Customized attributes, event control page display is added on the a tag
<!DOCTYPE html><html><head><script src="/jquery/jquery-1.11.1.min.js"></script></head><body><a data-a="a">aaaaaaaaaa</a><a data-a="a1">aaaaaaaaaa</a><a data-a="a2">aaaaaaaaaa</a><a data-a="a3">aaaaaaaaaa</a><script>$('a[data-a]').click(function(){alert($(this).attr('data-a'))})</script></body></html>