I am appending some html to a div using jQuery, where both rowString and inputString are defined previously:
$("#filterContainer").append(
rowString +
`<label class='filterLabel' for=${filter}>${filter}</label>` +
"<i class='fas fa-minus-circle removeFilter float-right'></i>" +
inputString +
"</div>"
);
rowString looks like this:
let rowString = "<input id='autocomplete' type='search' class='form-control' name='filters[location]' >"
And I am trying to inject a value into this. I've tried rowString.val('myvalue'), but it fails with Uncaught TypeError: string.val is not a function.
How can I add an html attribute such as value to a string?
rowStringis just a string but yourrowString.val(...)only works on jQuery objects. Create a jQuery object for it like Taplar does in his answer.