Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try something like: </p> <pre><code>$(".box").click( function() { if($(".activeBox").length &gt; 0) { //check if there is an activeBox element $(".activeBox").removeClass("activeBox"); //if there is, remove it } $(this).addClass("activeBox"); //make the clicked div the activeBox }); </code></pre> <p><code>.box</code> and <code>.activeBox</code> classes to be replaced by your own inactive and active selectors as you want.</p> <p>Here's a <a href="http://jsfiddle.net/maddest_march_hare/CFRvM/" rel="nofollow">jsFiddle</a> example</p> <p>Update:</p> <p>With the new HTML, I got this working as a <a href="http://jsfiddle.net/Cc5Ht/" rel="nofollow">jsFiddle</a></p> <p>Here's the code:</p> <p>HTML within jsFiddle's existing head/body tags:</p> <pre><code>&lt;div data-role="page"&gt; &lt;/div&gt; </code></pre> <p>CSS from OP:</p> <pre><code>div { outline:0; } div:hover { outline-width:1px; outline-color:red; outline-style: dotted; overflow:hidden; } .msp-selected { outline-width:1px; outline-color:red; outline-style: solid; } </code></pre> <p>jQuery: </p> <pre><code>$("div").click( function() { if($(".msp-selected").length &gt; 0) { $(".msp-selected").removeClass("msp-selected"); } $(this).addClass("msp-selected"); }); </code></pre> <p>I tested this with the various versions of jQuery available back to 1.7.2 and mobile 1.1.1, with the class being added on click each time. My only suggestion if this still doesn't work is to encase the whole thing in <code>$(document).ready( function() { //click function });</code> or switch to <code>$("div").on("click", function() {});</code></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