html - javascript function's parameter returning undefine -
function short_tag(tag, contents) { return "<" + tag + ">" + contents + "</" + tag + ">"; } document.getelementbyid("test-2").innerhtml = short_tag(p, okok); <div id="test-2"> </div> does know why error p not defined returning?
that's because p getting treated variable p should string. same okok
function short_tag(tag, contents) { return "<" + tag + ">" + contents + "</" + tag + ">"; } document.getelementbyid("test-2").innerhtml = short_tag("p", "okok"); <div id="test-2"> </div>
Comments
Post a Comment