Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to include html inside of javascript

i have javascript jquery that looks like this:

var userInput = prompt("Liquid Handler #:", "Liquid Handler #:");
$(this).next('a').text('Liquid Handler #:' + userInput);

i would like to know how i can include html into the text something like this:

var userInput = prompt("Liquid Handler #:", "Liquid Handler #:");
$(this).next('a').text('Liquid Handler #:' + '<b>' + userInput + </b>);

how do i inject html into the javascript?

like image 659
Alex Gordon Avatar asked Dec 06 '25 10:12

Alex Gordon


2 Answers

Use .html instead of .text.

$(this).next('a').html('Liquid Handler #:<b>' + userInput + '</b>');
like image 138
Michael Irigoyen Avatar answered Dec 07 '25 23:12

Michael Irigoyen


jQuery's .html() method should help.

like image 42
canon Avatar answered Dec 07 '25 22:12

canon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!