Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, the easiest way would be to reverse your logic and only apply this rule to elements that aren't supposed to be able to have their text selected. Problem with applying this rule to the whole body is that any child elements then already receive this overridden event from their parent (body) element, and the way to re-initialize <code>onselectstart</code> event isn't as easy as some seem to have assumed with their answers here. In your case, I would remove this rule for the whole body and then only apply it to the individual elements that don't have any children where the overriding rule must not apply. </p> <p><strong>Example:</strong></p> <pre><code>&lt;body&gt; this is some text that is selectable &lt;div style='-o-user-select: none; -webkit-user-select: none; -moz-user-select: -moz-none; -khtml-user-select: none; -ms-user-select: none; user-select: none;' onselectstart='return false;' unselectable='on'&gt; this is some text that's not selectable &lt;/div&gt; &lt;/body&gt; </code></pre> <p><strong>></strong> see working demo on <strong><a href="http://jsfiddle.net/6pXYN/4/" rel="nofollow">JSFiddle</a></strong></p> <hr> <p><em>Note that some individual properties listed aren't supported yet and I've added them anyway for future-proofing purposes. The rule-set is compiled in a way to support as many different browsers as possible. Some will obey CSS styling, some need a JavaScript hack (IE &lt; 10) and Opera browsers obey to a special element property (see below).</em></p> <p><strong>EDIT:</strong> Added support for Opera browsers (<code>unselectable='on'</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. VO
      singulars
      1. This table or related slice is empty.
    2. 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