Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That is the default behaviour in the browser for clicking on an <code>&lt;a&gt;</code> tag that has an <code>href</code> value of <code>#</code>. The <code>#</code> is reserved for jumping to sections on the page. As an easy example, if you have an <code>&lt;a&gt;</code> tag with an <code>href</code> of <code>#movies</code>, and a section on your page that has a <code>name</code> attribute that is also <code>movies</code>, then clicking on <code>&lt;a href="#movies"&gt;</code> will bring the user directly to the <code>movies</code> section of your page. If you simply have <code>#</code>, then the browser skips to the very top of the page, because you didn't specify a section name.</p> <p>To prevent this behaviour, you need to do at least this:</p> <pre><code>$(".my-links").on( 'click', function( evt ) { evt.preventDefault(); }); </code></pre> <p>And you may also need to include another line like this (depending on your selector/setup):</p> <pre><code>$(".my-links").on( 'click', function( evt ) { evt.preventDefault(); evt.stopPropagation(); }); </code></pre> <p><code>preventDefault()</code> will stop the default behaviour for a click on any element that matches the selector. See <a href="http://api.jquery.com/event.preventDefault/" rel="nofollow">here</a>.</p> <p><code>stopPropagation()</code> will stop the default event from bubbling up the DOM, so it doesn't get caught by any parent elements. See <a href="http://api.jquery.com/event.stopPropagation/" rel="nofollow">here</a>.</p> <p>Hope this helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload