search

Home  >  Q&A  >  body text

Unable to get color value

<form> 

<div>

 <input type="color" name="color" id="color"> <input type="button" name="btn" id="btn" value="获取颜色"> 

<input type="text" name="color_value" id="color_value"> </div></form> 

<script> document.getElementById('btn').onclick=function(){ document.getElementByid('color_value').value=document.getElementByid('color').value; } </script>

 我的代码哪里有问题?

ԾvԾ人人余耳总ԾvԾ人人余耳总2092 days ago1294

reply all(3)I'll reply

  • 团子

    团子2019-04-03 11:38:23

    What you are getting is the value of the DOM, and does not involve color. . .

    reply
    1
  • ԾvԾ人人余耳总

    This code is also used in the video tutorial. What should color.value be changed to?

    ԾvԾ人人余耳总 · 2019-04-03 21:54:23
  • Cancelreply