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

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -