javascript - HTML Creating a button that contains opens up a link in a new window -
i have been using document.write open link creating in new window.
document.write("<a target='blank' href='#"+link_number+"'>click here open link</a>");
link_number dynamic number creating( different every time ). trying put link in table is
<div id="tabs-10"> <table style="width:300px"> <tr><td><input type="button" id="link1" checked /> go link 1</td></tr> </table> </div>
i know how create button such how create html button acts link?
but question is, how can convert document.write button in table?
thank howard
you mean this?
var addbutton = function(text) { var btn = document.createelement('button'); var ttd = document.queryselectorall('td')[0]; btn.innerhtml = text; ttd.appendchild(btn); } document.queryselectorall('a')[0].onclick = function() { addbutton('random ' + math.random()); }
<div id="tabs-10"> <table style="width:300px"> <tr> <td> </td> </tr> </table> </div> <a>add button</a>
Comments
Post a Comment