snipt

Ctrl+h for KB shortcuts

JavaScript

Select all text content with jquery

1
2
3
$("someselector").click(function() {
    $(this).select();
});
https://snipt.net/embed/29b1a0f4ed6fa27b777edc641f3c6bb7/
/raw/29b1a0f4ed6fa27b777edc641f3c6bb7/
29b1a0f4ed6fa27b777edc641f3c6bb7
js
JavaScript
3
2019-06-22T06:05:11
True
False
False
/api/public/snipt/53903/
select-text-with-jquery
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;someselector&quot;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">select</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
"jquery select", "select all"