textarea

JQuery: .val() is not working for textarea

流过昼夜 提交于 2019-12-10 13:24:06
问题 I am trying to read the content of a textarea, but .val() does not work for my textarea. I would be happy, if someone has a solution for me. Here's my code: HTML: <textarea id="details" class="required" rows="5"></textarea> JS: $.ajax({ type: "GET", url: "reserve.php", data: { details : $('#details').val(), ... }, ... }); Thank you! 回答1: val() works just fine... You must have your error elsewhere. Example Probably your selector in not matching. Check for typos and if you applied the correct

Focus on textarea based from anchor link

限于喜欢 提交于 2019-12-10 12:29:48
问题 I have a messaging function in my site that when a user clicks on a reply button they get redirected to the message and have the textarea focus based from the anchor link. so the link structure is like this: view_message/4fad37da1df#reply thanks 回答1: Try: if (window.location.hash) { $(window.location.hash).attr("tabindex", -1).focus(); } It should check if the url has a hash in it, and if it does, give the target the tabindex attribute with a value of -1 and apply focus. See https:/

html - Get wrapped text from textarea

给你一囗甜甜゛ 提交于 2019-12-10 11:52:37
问题 I'm trying to get the word wrapped line breaks from a textarea without having make any server calls. This answer gets me 90% of the way there. The problem is that the page is reloaded inside of the iframe each time the submit button is clicked. Here's the code: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <html> <body> <script type="text/javascript"> function getURLParameter(qs, name) { var pattern = "[\\?&]" + name + "=([^&#]*)"; var regex = new

show html output in textarea instead of HTML code

我与影子孤独终老i 提交于 2019-12-10 11:25:20
问题 If I have a textarea including some HTML code, how can I write a JavaScript function to show the HTML output instead of HTML code itself, for example: <textarea id="mytextarea"> <table border=1><tr><td>cellone</td>td>celltwo</td></tr></table </textarea> <input type=button onclick="HTMLoutput();"/> <script> HTMLoutput() { //Code to show html output instead of html code in textarea } </script> How can I do this? What is the suggested code to write inside the HTMLoutput()? 回答1: So to convert the

Allow a textarea resize to shrink (not just grow) element from its original/default size

荒凉一梦 提交于 2019-12-10 04:00:20
问题 I am trying to create a textarea element that has a programmatically-defined original/default size, but which the user can resize within defined limits that allow it to both grow and shrink. I have tried setting the resize , min-width , max-width , and width properties of the text-area, but, thus far, this only allows the user to grow the textarea element, not shrink it. The browser will allow the user to size and resize the element within the bounds of width and max-width , not between the

How to add a keyboard listener to my onClick handler?

六月ゝ 毕业季﹏ 提交于 2019-12-10 03:56:28
问题 I have the following: class MyTextArea extends React.Component { handleClick = () => { this.focus(); } focus = () => this.ref.focus; handleRef = (component) => { this.ref = component; }; render() { return ( <div className="magicHelper" onClick={this.handleClick}> <textarea></textarea> </div> ); } } My CSS: .magicHelper { width: 100%; height: 100%; } textarea { line-height: 32px; } I need this because I need the textarea's placeholder are to be horizontally and vertically centered in the page.

Jquery .val() not returning line-breaks in a textarea

懵懂的女人 提交于 2019-12-09 19:30:37
问题 I got problem with line breaks in a textarea. I get the text with .val() function: var messageBody = $('#composeInput').val(); This is my ajax request $.ajax({ url: 'serverScripts/messages/addMessage.php', data: 'messageBody='+messageBody+'&invitedJSONText='+invitedJSONText, success: function(){ //Do something } }); And PHP: $messageBody = nl2br(mysql_real_escape_string($_GET['messageBody'])); The text: Hi! How are you? Becomes: Hi! How are you? If I insert the variable messageBody to an

Angular2 maxLength for textarea as variable

送分小仙女□ 提交于 2019-12-09 18:13:37
问题 To set max letters number for textarea, we do achieve that by writing: <textarea maxLength="50"></textarea> but, could I do something like below? Is there some way? import { Component } from '@angular/core'; @Component({ moduleId: module.id, selector: 'app-create-offer-page', template: ` <textarea maxLength="textareaLength"></textarea> ` }) export class CreateOfferPageComponent { textareaLength: number = 50; } I'm asking because that does not work. 回答1: You would need [] for Angular to

How can i change hashtag color on textarea by jquery

回眸只為那壹抹淺笑 提交于 2019-12-09 13:26:42
问题 i wanna make hash tag on textarea like this <textarea> hi #hash </textarea> and change color of #hash like twitter 回答1: I made a plugin for this because I had the same problem. Look here: http://lookapanda.github.io/jquery-hashtags/ 回答2: A simple suggestion (not tested): As you cannot format a textarea, you can imitate it by using a div with the contenteditable attribute and a simple CSS formatting: <div id='textarea' contenteditable style="overflow: scroll; border: 1px solid black; width:

Textarea Height increase

拜拜、爱过 提交于 2019-12-09 12:19:06
问题 How to increase the height of the text area as and when we type to a max of 50px from 18px. then if someone types more the scrollbar should take over. is this possible ? 回答1: You can use either of these plugins: TextAreaExpander (Demo) autoResize Plugin 回答2: That's JQuery Elastic. It might be your requirement. :) 来源: https://stackoverflow.com/questions/4176783/textarea-height-increase