Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在html页面中使用javascript动态添加按钮_Javascript - Fatal编程技术网

如何在html页面中使用javascript动态添加按钮

如何在html页面中使用javascript动态添加按钮,javascript,Javascript,我想使用java脚本在HTML页面上动态添加按钮。请告诉我怎么做 var button = document.createElement("input"); input.type = "button"; var whatever;//get whatever you want to append button to whatever.appendChild(button); 只需创建您的按钮,并使用appendChild将其添加到您想要的任何dom元素中…您能在您的问题上投入更多精力吗?向

我想使用java脚本在HTML页面上动态添加按钮。请告诉我怎么做

var button = document.createElement("input");
input.type = "button";

var whatever;//get whatever you want to append button to

whatever.appendChild(button);

只需创建您的按钮,并使用appendChild将其添加到您想要的任何dom元素中…

您能在您的问题上投入更多精力吗?向我们展示您的尝试、遇到的困难等。这取决于您的努力,这不是一项为您服务的服务。欢迎光临,我很高兴能为您提供帮助!