jquery - Using Javascript variables within a string -
this question has answer here:
- how add var text javascript 4 answers
i using jquery output link webpage. part of link dynamic, , having trouble using variables , text together. variable gets treated text. doing wrong?
my jquery:
var new_collection_id= 1; var new_collection_title= 'this title'; .html('<a href="collection.php?id=1&collection=new_collection_id"> new_collection_title </a>')
you need use concatenation.
.html('<a href="collection.php?id=1&collection=' + new_collection_id + '">' + new_collection_title + ' </a>')
Comments
Post a Comment