I want to disable text selection when I click more than one. I’m handling the double click event on a span in my website. A side-effect is that the double click selects text on the page. How can I disable text selection after the double click?
If I am followed this code, what can I do to disable text selection?
<span>up</span><span>1</span><span>down</span>
Put span in a div and add a class name in your span tag.
<div class="my-div"> <span class="span-class">up</span><span class="span-class">1</span><span class="span-class">down</span> </div>
Apply this CSS code:
<style> .my-div .span-class { -webkit-user-select: none; /* webkit (safari, chrome) browsers */ -moz-user-select: none; /* mozilla browsers */ -khtml-user-select: none; /* webkit (konqueror) browsers */ -ms-user-select: none; /* IE10+ */ } </style>
Question and answer is powered by AnsPress.io