I am trying to concatenate the value of the input with the String variable. For instance: (lets say that the input with an id 'input1' has the value of 'tttttt')
var test = 'blabla' + $('#input1').val() + 'blabla';
So the expected result (at least for me) should be 'blablattttttblabla'.
The problem is that it does not insert the value of that input in the middle so the result is 'blablablabla'.
Does someone has an idea what I am doing wrong?
.val()returns an empty string. Are you sure that field is there and it's the only one with that id?$('#input1').val()in the console and see what the result is.$('#input1').val()by itself? My guess is that your selector is wrong.input1has a value. can you show the scope in which this is being called?$('#input1').lengthreturn 1