jquery - How to change the formatting (eg make bold) only the first 5 words typed in a form -


i change formatting of first 5 words user inputs textarea automatically (eg looks para).

i know there way value of text input in jquery using:

$('input').keyup(function() {   $('span').text($(this).val()); }); 

however, have no idea whether possible change formatting of first few words user types, while typing it. reason wish because have comment system "title" of comment first 5 words of textarea of comment, , want people recognise while typing (as part of ui feedback). can done? how? thanks!

$('input').keyup(function() {   var txt = $(this).val();   var re=new regexp("\\s+(?: \\s+(?: \\s+(?: \\s+(?: \\s+)?)?)?)?");   var beginning = re.exec(txt);   $('span').text(beginning);   var rest = txt.substring(beginning.length); // start space }); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -