jQuery val('') does not clears new lines?
Or i'm doing something wrong?
$('textarea').val('')
keeps new li开发者_如何学编程ne in textarea if there were any of them.
Any solution?
Hmm jQuery 1.4.4 does not do it like you say either in Chrome, FF3.6 or IE8, here is a demo :
http://jsfiddle.net/subtenante/abk3V/
Add new line characters in the textareas, click on "empty!" and all the characters disappear.
I have spotted this issue second time in another project and decided to figure out what is happening. Started to dig and figured out it was \n in textarea.
Started to watch the process of textarea usage and found that there were mistake in the code inside handler for keydown of textarea.
I forgot to return false at the end. That's why key "enter" were adding additional \n in the textarea. :D
Maybe that helps anyone.
Sorry everyone. Topic is closed :)
精彩评论