Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.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
Javascript 为什么赢了';当使用JS创建时,我的选择是否会显示一个选项?_Javascript_Html_Css - Fatal编程技术网

Javascript 为什么赢了';当使用JS创建时,我的选择是否会显示一个选项?

Javascript 为什么赢了';当使用JS创建时,我的选择是否会显示一个选项?,javascript,html,css,Javascript,Html,Css,这似乎并没有创建下拉列表,即使我创建了一个附加在select中的option元素,也没有用于Arial的选项 const sheets=document.getElementById('sheets'); const siteDocument=document.getElementsByTagName('body')[0]; const popup=document.getElementById('popup'); const buttons=document.getElementById('

这似乎并没有创建下拉列表,即使我创建了一个附加在select中的option元素,也没有用于Arial的选项

const sheets=document.getElementById('sheets');
const siteDocument=document.getElementsByTagName('body')[0];
const popup=document.getElementById('popup');
const buttons=document.getElementById('buttons');
constToolResult=document.getElementById('toolresult');
const item=document.getElementById('item');
//const sheets=document.getElementById('sheets');
/*弹出窗口*/
const myStuff=prompt('Enter'列,行\'注:建议在计算机上使用5,20,请参阅文档');
if(myStuff!=''| | myStuff.includes(',')==true){
常量myStuffArr=myStuff.split(',');
console.log(myStuffArr);
window.amountOfColumns=myStuffArr[0];
window.amountOfRows=myStuffArr[1];
}否则{
window.amountOfColumns=5;
window.amountOfRows=20;
}
/*功能*/
const itemVisible=document.getElementById('itemVisible');
功能变更项目(测试){
itemVisible.value=test.slice(test.indexOf('t')+1,test.length);
}
函数showProperties(){
const forButton=document.createElement('select');
forButton.setAttribute('type','text')
toolresult.appendChild(forButton)
const option=document.createElement('option');
option.setAttribute('value','Arial')
forButton.appendChild(选项)
}
var计数器=0;
对于(var x=0;x对于(var j=1;j请尝试以下内容。我已更改了行文档.getElementById('toolresult').appendChild(forButton))以及如何向选项添加值和html

function showProperties() {
  const forButton = document.createElement('select');
  forButton.setAttribute('type', 'text')
  toolresult.appendChild(forButton)
  const option = document.createElement('option');
  option.setAttribute('value', 'Arial')
  forButton.appendChild(option)
}
完整代码如下

const sheets=document.getElementById('sheets');
const siteDocument=document.getElementsByTagName('body')[0];
const popup=document.getElementById('popup');
const buttons=document.getElementById('buttons');
constToolResult=document.getElementById('toolresult');
const item=document.getElementById('item');
//const sheets=document.getElementById('sheets');
/*弹出窗口*/
const myStuff=prompt('Enter'列,行\'注:建议在计算机上使用5,20,请参阅文档');
if(myStuff!=''| | myStuff.includes(',')==true){
常量myStuffArr=myStuff.split(',');
console.log(myStuffArr);
window.amountOfColumns=myStuffArr[0];
window.amountOfRows=myStuffArr[1];
}否则{
window.amountOfColumns=5;
window.amountOfRows=20;
}
/*功能*/
const itemVisible=document.getElementById('itemVisible');
功能变更项目(测试){
itemVisible.value=test.slice(test.indexOf('t')+1,test.length);
}
函数showProperties(){
const forButton=document.createElement('select');
document.getElementById('toolresult').appendChild(forButton)
const option=document.createElement('option');
option.value='Arial';
option.innerHTML='Arial';
forButton.appendChild(选项)
}
var计数器=0;
对于(var x=0;x对于(var j=1;jdid,您是否将
forButton
附加到文档中?@Nick yes,它被附加到toolresult,这是我没有包含的一个div。
function showProperties() {
  const forButton = document.createElement('select');
  document.getElementById('toolresult').appendChild(forButton)
  const option = document.createElement('option');
  option.value = 'Arial';
    option.innerHTML = 'Arial';
  forButton.appendChild(option)
}