Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Because jQuery and JavaScript are closely related (jQuery being the write less, do more version of JavaScript), you can assign an <code>event listener</code> using JavaScript and write what happens if the event is triggered in jQuery. I would personally assign the translator an id, get that element by it's id, and assign an <code>event listener</code> to it. <a href="http://www.howtocreate.co.uk/tutorials/javascript/domevents" rel="nofollow">Some more information on event listeners</a>.</p> <p>If you are only assigning one listener per element (and their <code>&lt;div&gt;</code> that they are located in does not have an event listener), then you can use this type of <code>event listener</code>: </p> <pre><code>var saveButton = document.getElementById('savebuttonId'); saveButton.addEventListener('click',myCustomFunction,true); </code></pre> <p>Or if you only need to use the function once, say to tell someone their progress was saved, and that's the only reason you need a function like that, you can do this:</p> <pre><code>var saveButton = document.getElementById('savebuttonId'); saveButton.addEventListener('click' function() { alert('Progress saved!'); }, true); </code></pre> <p>If the button is located in a <code>&lt;div&gt;</code> element that also has an event listener, you can specify the order it goes in. Just replace, <code>}, true);</code> with <code>}, ORDER, true);</code> If you do not do this, the functions could go in any order that they want, which usually varies on the browser the person is using.</p>
 

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