Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>&lt;input type="checkbox" id="clickme" name="Notifications"&gt; Notifications&lt;br /&gt; &lt;div id="notifications"&gt;Notifications&lt;/div&gt; $('#clickme').click(function() { $('#notifications').toggle('slow', function() { // some code after completion }); }); </code></pre> <p>the question marks could be replaced with some code if you would like to have some other effect, like a css change or some other event. it is not necessary so you can remove it by using this instead.</p> <pre><code>$('#clickme').click(function(){ $('#notifications').toggle('slow'); }); </code></pre> <p>with this code above you will have a checkbox and beside it will be the text Notifications, the .click function will be executed when someone clicks on the checkbox, when this happens the .toggle function will then be executed. What the .toggle function does is it switches the display property on the #notifications element (so your div that contains notifications). so when you click the checkbox it will switch the notifications between being hidden and visible.</p> <p>As for the code, "//some code after completion" this is where you could have put further code that you would like to have executed, if you aren't sure what that is for its likely that you don't need that section so you can use the second sample code that I put. You should add this code within javascript tags on your page within your init function like:</p> <pre><code>$(document).ready(function(){ //the code I showed above }); </code></pre>
 

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