开发者

live wrapping words from a input field(jQuery)

开发者 https://www.devze.com 2023-03-06 20:09 出处:网络
Looking for a way to wrap words that have been enterd in a text field. Words that have been seperated by a space should be wrapped and displayed below the text field(like tags).

Looking for a way to wrap words that have been enterd in a text field. Words that have been seperated by a space should be wrapped and displayed below the text field(like tags).

I cant find a tutorial on the web.so a开发者_StackOverflownybody here any ideas how to do this?


$('input').observe('keyup', function(){
    $('tags').update($('input').value.replace(/\s/g, '<br/>'));
});

Working demo: http://jsfiddle.net/SkYpg/

Note: The demo has been done with Prototype rather than jQuery, since I'm more familiar with that. It should be easy to convert, though..

0

精彩评论

暂无评论...
验证码 换一张
取 消