Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure what you mean by <em>"selected by user text"</em>, but if you mean that you want the user to be able to click on the text to remove its color, you could do it this way with jQuery:</p> <p><strong>Try it out:</strong> <a href="http://jsfiddle.net/v24fZ/" rel="noreferrer">http://jsfiddle.net/v24fZ/</a></p> <pre><code>$(function() { $('div &gt; span').click(function() { $(this).removeAttr('style'); }); }); </code></pre> <p>Note that this will affect all <code>&lt;span&gt;</code> elements that are a child of a <code>&lt;div&gt;</code>, so better would be to place an ID attribute on the <code>&lt;div&gt;</code> to make sure you have the right one.</p> <p><strong>Try it out:</strong> <a href="http://jsfiddle.net/v24fZ/1/" rel="noreferrer">http://jsfiddle.net/v24fZ/1/</a></p> <pre><code>&lt;div id="myID"&gt;&lt;span style="color:red;"&gt;a&lt;/span&gt;&lt;span style="color:blue;"&gt;a&lt;/span&gt;&lt;span style="color:white;"&gt;a&lt;/span&gt;&lt;/div&gt; </code></pre> <p>then</p> <pre><code>$(function() { $('#myID &gt; span').click(function() { $(this).removeAttr('style'); }); }); </code></pre> <p>Also note that this will remove <em>all</em> inline styles. If you only want to remove the color, then do this:</p> <p><strong>Try it out:</strong> <a href="http://jsfiddle.net/v24fZ/2/" rel="noreferrer">http://jsfiddle.net/v24fZ/2/</a></p> <pre><code>$(function() { $('#myID &gt; span').click(function() { $(this).css('color', ''); }); }); </code></pre> <ul> <li><a href="http://api.jquery.com/removeAttr/" rel="noreferrer">http://api.jquery.com/removeAttr/</a></li> <li><a href="http://api.jquery.com/css/" rel="noreferrer">http://api.jquery.com/css/</a></li> <li><a href="http://api.jquery.com/click/" rel="noreferrer">http://api.jquery.com/click/</a></li> </ul>
 

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