Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have been trying to answer your question and I have created a little jQuery(1.5.2) code. Hope this would help just have a look and tell me is this what you are looking for?, or if you want something else I can made it too. In this script on clicking a <code>div</code> element with id <code>on_off</code> (You can select it too by using var!) and class for on (<code>on_off_on</code>) and off (<code>on_off_off</code>) and by the way you can select them too, just get to this jsFiddle link for <a href="http://jsfiddle.net/divinemamgai/qCnyM/" rel="nofollow">live demo</a> or you can see the script below --</p> <p>HTML --</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js" &gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="on_off" class="on_off_on" &gt;ON&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>CSS --</p> <pre><code>div.on_off_off { background: rgb(150,110,120); font-family: segoe ui; font-size: 12px; font-weight: bold; padding: 5px 10px; border: 3px solid rgb(180, 140, 150); border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; color: #fff; display: inline; } div.on_off_on { background: rgb(110,150,120); font-family: segoe ui; font-size: 12px; font-weight: bold; padding: 5px 10px; border: 3px solid rgb(140, 180, 150); border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; color: #fff; display: inline; } </code></pre> <p>jQuery Code --</p> <pre><code>$(document.body).ready(function () { $(function () { var main_obj_id = 'on_off'; var on_class = 'on_off_on'; var off_class = 'on_off_off'; $('#' + main_obj_id).click(function () { if ($(this).is('.' + on_class)) { $(this).removeClass(on_class); $(this).addClass(off_class); $(this).html('OFF'); } else { $(this).removeClass(off_class); $(this).addClass(on_class); $(this).html('ON'); } }); }); }); </code></pre> <p>Hope this would help!</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      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