'How to concatenate a variable with string text for displaying as placeholder of an input [duplicate]
I have this script for adding new input field when user click on a link with id of add:
$(document).ready(function() {
var i = 1;
$('#add').click(function(){
i++;
$('#dyanimc-field').append("<input type='text' name='tag_name[]' value='' class='form-control' id='tagInput' placeholder='Tag name'+i>");
});
});
Now this works fine and properly adds a new input field but I want the placeholder of this input to be showing the value of i variable next to the Tag name text.
So the inputs would have these placeholder:
Therefore I tried this placeholder='Tag name'+i> but this is wrong because it does not return any i variable value!
So how to concatenate a variable with string text for displaying as placeholder of an input correctly?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

