You may want to set a breakpoint within the event handler for the textarea 
to track down where the new line comes from. Though it sounds like the new 
line comes from hitting Enter within the textarea.
As Farshid mentioned you can prevent the default behavior (i.e. entering a 
new line) when hitting Enter using 
event.preventDefault()<https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault>,
 
though his code has a little flaw as it's not the click event you need to 
react to but the keydown event. So the code would actually look something 
like this (with some other improvements):

textarea.addEventListener("keydown", function(event) {
  if (event.keyCode === KeyEvent.DOM_VK_RETURN) {
    event.target.value = "";
    event.preventDefault();
  }
});

Sebastian

On Thursday, May 22, 2014 10:03:09 PM UTC+2, Farshid Beheshti wrote:
>
>
> I have a textarea where the user enters the answer to a question. If he 
>> enters the wrong answer, or no answer (just hits the enter key), the script 
>> clears the textarea.  When it clears the textarea, I end up with a new line 
>> that I don't want.
>>
>  
> I think you don't need to do anything with Firebug. Add 
> *event.preventDefault();* at the end of the function handling the event 
> when a return key is pressed, something like this:
>
> textarea.click = function(event){
> if(event.keyCode == 13){
> event.preventDefault();
> }
> }
> Note |event| is the name of the argument.
>
> Although the answer doesn't relate to the Firebug, but just as way to fix 
> the issue.
>
> Farshid
>
>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Firebug" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to firebug+unsubscr...@googlegroups.com.
>> To post to this group, send email to firebug@googlegroups.com.
>> Visit this group at http://groups.google.com/group/firebug.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/firebug/5bffeedf-a296-44df-a64c-ef349379e081%40googlegroups.com<https://groups.google.com/d/msgid/firebug/5bffeedf-a296-44df-a64c-ef349379e081%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to firebug+unsubscr...@googlegroups.com.
To post to this group, send email to firebug@googlegroups.com.
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/firebug/974076c1-03f3-4352-9de1-277f3f2ee677%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to