Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Binding:</p> <ul> <li><code>javascript:</code> URLs are a horror to be avoided at all times;</li> <li>inline event handler attributes aren't brilliant either, but OK for a bit of rapid development/testing;</li> <li>binding from script, leaving the markup clean, is typically considered a best practice. jQuery encourages this, but there is no reason you can't do it in any library or plain JS.</li> </ul> <p>Responses:</p> <ul> <li>In jQuery <code>return false</code> means both <code>preventDefault</code> and <code>stopPropagation</code>, so the meaning is different if you care about parent elements receiving the event notification;</li> <li>jQuery is hiding it here but <code>preventDefault</code>/<code>stopPropagation</code> have to be spelled differently in IE usually (<code>returnValue</code>/<code>cancelBubble</code>).</li> </ul> <p>However:</p> <ul> <li>You have a link that isn't a link. It doesn't link anywhere; it's an action. <code>&lt;a&gt;</code> isn't really the ideal markup for this. It'll go wrong if someone tries to middle-click it, or add it to bookmarks, or any of the other affordances a link has.</li> <li>For cases where it really does point to something, like when it opens/closes another element on the page, set the link to point to <code>#thatelementsid</code> and use unobtrusive scripting to grab the element ID from the link name. You can also sniff the <code>location.hash</code> on document load to open that element, so the link becomes useful in other contexts.</li> <li>Otherwise, for something that is purely an action, it would be best to mark it up like one: <code>&lt;input type="button"&gt;</code> or <code>&lt;button type="button"&gt;</code>. You can style it with CSS to look like a link instead of a button if want.</li> <li>However there are some aspects of the button styling you can't quite get rid of in IE and Firefox. It's usually not significant, but if you really need absolute visual control a compromise is to use a <code>&lt;span&gt;</code> instead. You can add a <code>tabindex</code> property to make it keyboard-accessible in most browsers although this isn't really properly standardised. You can also detect keypresses like Space or Enter on it to activate. This is kind of unsatisfactory, but still quite popular (SO, for one, does it like this).</li> <li>Another possibility is <code>&lt;input type="image"&gt;</code>. This has the accessibility advantages of the button with full visual control, but only for pure image buttons.</li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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