textarea

Highlighting a piece of string in a TextArea

 ̄綄美尐妖づ 提交于 2019-11-30 08:50:52
问题 I'm trying to highlight a piece of text in a "Textarea". I have a long string in that TextArea: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident And I have a

JavaScript: Scroll to selection after using textarea.setSelectionRange in Chrome

北战南征 提交于 2019-11-30 08:40:31
A javascript function selects a certain word in a textarea using .setSelectionRange(). In Firefox, the textarea automatically scrolls down to show the selected text. In Chrome (v14), it does not. Is there a way to get Chrome to scroll the textarea down to the newly selected text? jQuery solutions welcome. Here is a simple and efficient solution, pure js : //first of all, you ignore any bad english, as i'm french and had a funny evening //get the textarea var textArea = document.getElementById('myTextArea'); //define your selection var selectionStart = 50; var selectionEnd = 60; textArea

Copy from textarea to div, preserving linebreaks

倾然丶 夕夏残阳落幕 提交于 2019-11-30 08:38:08
I've got a <textarea> and a <div> (with a <p> inside). When entering text into the area, the <p> gets updated with the content upon keyUp. Is there a way to preserve linebreaks (new line) from the textarea and somehow get them to work like linebreaks in the div/p? Replacing double "new line" with </p><p> , is that possible as well? This is close to what a wysiwyg would handle, but don't want that for this, wich is a very small project. This is what I've got so far. $(".box textarea").keyup(function () { var value = $(this).val(); $('.box p').text(value); }); You can simply do this: $('.box

jQuery text() function loses line breaks in IE

别等时光非礼了梦想. 提交于 2019-11-30 08:37:18
问题 This is quite a talked about problem on the jQuery forums but I can't figure out a solution for my situation. I have an unordered list with some text elements in them... the user can create new list items via jQuery, which are saved to an SQL database. They can also edit existing list items. Also, because the text in each list item can get quite long, they have the option of 'hiding' each list item so it shows a truncated version of the string. This is handled by a custom jQuery plugin that

HTML5 rich-text inside textarea

五迷三道 提交于 2019-11-30 08:26:29
问题 I heard that the new HTML5 will add rich text capability to textareas (it will make them more flexible), so you can do stuff like code syntax highlighting editors without very nasty javascript (like creating iframes and stuff). Is this true? Are there browsers with support for it yet? And where can I find some API? 回答1: NO - jQuery If what you where looking for (the same as me) is NO-jquery tools (pure HTML/CSS + basic JS), then some of the best options I found are: wysihtml5 Squire ckeditor

Line breaks in textarea element

做~自己de王妃 提交于 2019-11-30 08:01:20
This is PURE HTML. (no php or anything like that, if you want to know the background its a C# application with HTML in a web view). All my HTML files are nicely formatted and correctly indented for maintainability and such. Here is an excerpt: <tr> <td class="label">Clinic Times:</td> <td><textarea name="familyPlanningClinicSessionsClinicTimes">Monday: Tuesday: Wednesday: Thursday: Friday: Saturday: Sunday:</textarea></td> </tr> The line breaks in the <textarea></textarea> element are there to get the line breaks on the page. However it also includes the indentation in the textarea element. e

javascript | save textarea value with line breaks

社会主义新天地 提交于 2019-11-30 06:56:53
问题 I have a code where it saves multiple textarea values in a text file. However, it does not display the line breaks I indicated after saving it. It only identifies the line breaks w/c are manually put within the textarea. Below is the code. Please help. <script> var TestVar = new Array(); var i = 0; function save() { TestVar[i] = document.getElementById("text1").value + "\n" + document.getElementById("text2").value; mydoc = document.open(); mydoc.write(TestVar); mydoc.execCommand("saveAs",true

How to validate pattern matching in textarea?

南楼画角 提交于 2019-11-30 06:45:14
问题 When I use textarea.checkValidity() or textarea.validity.valid in javascript with an invalid value both of those always return true, what am I doing wrong? <textarea name="test" pattern="[a-z]{1,30}(,[a-z]{1,30})*" id="test"></textarea>​ jQuery('#test').on('keyup', function() { jQuery(this).parent().append('<p>' + this.checkValidity() + ' ' + this.validity.patternMismatch + '</p>'); }); http://jsfiddle.net/Riesling/jbtRU/9/ 回答1: HTML5 <textarea> element does not support the pattern attribute.

jQuery - remove user input text from textarea

帅比萌擦擦* 提交于 2019-11-30 06:37:37
Okay I have a list of devices where i can select which to edit. I have 3 states for the edit. When no devices are selected, when 1 device is selected or when x devices are selected. The problem i have is when a user type some text in the textarea (commentField) and cancels the edit to edit another device, the text there was typed in the textarea won't disapere. It stays so when i get the new dialog for the new edit, the commentfield has the text from the old commentField (as if it wasn't cleared) I have tried the following codes to remove the text (both when then cancel button is pressed and

div resizable like text-area

邮差的信 提交于 2019-11-30 06:35:07
问题 Browsers allow text-areas to be re-sized by dragging their corner by default. I was wondering if this rule could be applied to other elements (a div for instance). I know this effect could be achieved using the jQuery draggable or the jQuery-ui resizable function, but I would like to do it with plain html / css if it is possible to avoid relying on that library. Are their any CSS rules that I could apply to a div to make it behave in this way? If you have any other solution I would like to