Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;textarea id="textarea" style="width:500px;height:200px;"&gt;Lorem ipsum dolor sit amet, consectetur &lt;adipiscing&gt; elit. Aliquam adipiscing feugiat vestibulum. &lt;Proin risus massa&gt;, cursus quis eleifend tristique, pharetra eget ligula. &lt;Suspendisse potenti&gt;. Etiam vel lectus ante. Fusce varius laoreet lobortis. Aliquam ornare dictum lacus, non pharetra mauris fringilla sit amet. Quisque accumsan viverra dui, non pellentesque arcu bibendum et. Sed vel odio in libero scelerisque posuere. Phasellus euismod leo non arcu vulputate in sollicitudin sem facilisis. Morbi et dui luctus sem molestie commodo ac vel justo.&lt;/textarea&gt; &lt;script type="text/javascript"&gt; var textarea = document.getElementById("textarea"); textarea.onclick = textarea_Click; function textarea_Click() { var caret = getCaretPosition(textarea); var text = textarea.value; var begin = caret - 1; while (begin &gt;= 0) { if (text.charAt(begin) == '&gt;') return; else if (text.charAt(begin) == '&lt;') break; else begin--; } if (begin &gt;= 0) { var end = caret; while (end &lt; text.length) { if (text.charAt(end) == '&gt;') break; else end++; } if (end &lt; text.length) setSelection(textarea, begin, end); } } function getCaretPosition(el) { if (el.selectionStart) { return el.selectionStart; } else if (document.selection) { var r = document.selection.createRange(); if (r == null) return 0; var re = el.createTextRange(); var rc = re.duplicate(); re.moveToBookmark(r.getBookmark()); rc.setEndPoint('EndToStart', re); return rc.text.length; } return 0; } function setSelection(el, begin, end) { if ("selectionStart" in el) { el.selectionStart = begin; el.selectionEnd = end + 1; } else if (document.selection) { var range = el.createTextRange(); range.collapse(true); range.moveEnd('character', end + 1); range.moveStart('character', begin); range.select(); } } &lt;/script&gt; </code></pre> <hr> <p>EDIT: Since you're using jQuery, the <a href="http://laboratorium.0xab.cd/jquery/fieldselection/0.1.0/test.html" rel="nofollow">fieldSelection plugin</a> might make things a lot cleaner.</p> <p>As for a simple regex solution, nothing immediately comes to mind, but I'm also no regexpert :)</p> <p>EDITED AGAIN: I changed my original code so that it now supports IE. Tested in Firefox, Chrome, and IE 6/7/8.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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