How do I add an input form when clicking an HTML link using javascript? -
this question has answer here:
i want have div
containing link. when clicked, link should replaced <input type="text">
, doesn't work.
any other html code works, reason can not replace link input:
function working() { document.getelementbyid("working").innerhtml = "<h1>test</h1>"; }; function notworking() { document.getelementbyid("notworking").innerhtml = "<input type="text">"; };
<div id="working"> <a onclick="working();" href="#">this works!</a> </div> <div id="notworking"> <a onclick="notworking();" href="#">this doesn't!</a> </div> <p> notice entire code doesn't work unless comment out "notworking()" function! </p>
you need single quotes nested quotes;
function notworking() { document.getelementbyid("notworking").innerhtml = "<input type='text'>"; }
i've done many times haha, when using quotes inside double quotes use single quotes.
hope helps!
Comments
Post a Comment