Steve. Application Security Consultant, PHP Web Developer, thinks open source, loves people, writing, languages and calvin & hobbes. My code to clear out the tags – Tom Sep 21 '12 at 10:51 @Tom:Thanks.There were spaces between tags.Working. Loop Images in a HTML JavaSacript - Change ), You are commenting using your Google account. How to Get & Set Cursor Position in Textarea. Get user input from input tag using jQuery $("input']").val(); Javascript: Positioning the cursor at the beginning of a textarea, Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. Anything that does not contribute and is just spam will automatically be deleted. ? Anything that does not contribute and is just spam will automatically be deleted. Works OK so far. Application Security, Infrastructure Vulnerability Management, Trends, Challenges, Remediation and what not! Share this Question 3 Replies . Rather than just using a plain textarea with the contents of the template files, I wanted to add some simple functions with javascript. Markup. Change ), You are commenting using your Twitter account. So if you could tell me what the name of that is, that'll be great. The problem is, the cursor remains on the 2nd line. Write powerful, clean and maintainable JavaScript. Have fun ! The javascript code to put the cursor in a textbox or textarea at the beginning is pretty much identical to the code above with the difference of just specifying the position variable of 0. COMMENTS ON DEMONSTRATION USING JAVASCRIPT TO PUT MOUSE CURSOR IN INPUT TEXT OR TEXTAREA AT THE BEGINNING Feel free to submit your comment below. Last Updated: January 31, 2014. After some frantic google searching, I found the below javascript would fix this discrepancy. I got foll. How do you get the cursor position in a textarea?, I have a textarea and I would like to know if I am on the last line in the textarea or the first line in the textarea with my cursor with JavaScript. 1. – user1495475 Sep 21 '12 at 10:59 Also, there is no need to write css in ALL CAPS – Daniel F Jun 7 '15 at 20:16 This can also be used to select portions of text: document.getElementById('myTextBox').setSelectionRange(startPos, endPos); 435. selectionEnd : unsigned long: Returns / Sets the index of the end of selected text. View 3 Replies View Related Position Cursor In A Textarea On A Line Number? Open in new window. The problem is, the cursor remains on the 2nd line. 2. It's for a message reply form and when the page loads I would like the cursor to be in the text box above the quoted text. ( Log Out /  But sometimes, this won’t work even if you replace it with [0].click(). If the field contains a selection, the selected text will be replaced with a given one. I would like to keep the displayed area replybox.setSelectionRange(0,0); In Chrome, text is inserted at first position of textarea. Let's say I had a simple textarea with some values already filled in.  The below code will always insert the desired text at the beginning of the