javascript - Add <span> to innerHTML with value -
based off thread: using css stylesheet javascript .innerhtml
to stylize innerhtml such this:
document.getelementbyid("id").innerhtml = "this error"; all need this:
document.getelementbyid('error-message').innerhtml = "<span class='error'>my error</span>"; but if have value? how apply tag this:
document.getelementbyid('ptext').innerhtml = "you clicked: " + value;
innerhtml string that's converted / interpreted html, long add tags around value, it'll work:
document.getelementbyid('ptext').innerhtml = "<span>you clicked: " + value + "</span>"; alternatively, add span html directly, , set innerhtml of span "you clicked :" + value in js, bit cleaner.
Comments
Post a Comment