javascript - Need to append text to beginning of input field. -


in following code, send text server, want username appended beginning of field. ideas on how can done? prototype solution below.

function chatsend(){     console.log(input.value)     input.value = name+":"+input.value; //   $.ajax({        type: "post",        url: "https://api.parse.com/1/classes/chats",                   data: json.stringify({text: $('input').val()}),         success:function(message){          }   }); } 

did not work? wrote , works fine:

chatsend($('.inp'));  function chatsend(input){     console.log($(input).val())     $(input).val("username" + ":" +$(input).val());      console.log($(input).val()) } 

fiddle demo


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -