如何通过javascript设置输入文本框(属于JSColor类)的值?我想改变背景颜色和输入值(通过Javascript命令或Jquery )。够好了)。
谢谢。
发布于 2018-05-09 07:39:48
使用jquery
var yourinputid = $('#YOURINPUTID') //save some resources by not duplicating the selector
yourinputid.val('yourcolor'); //set the value
yourinputid.css('background-color', '#yourcolor'); //set the background color没有jquery
var yourinputid = document.getElementById('YOURINPUTID'); //save resources..
yourinputid.value = 'yourcolor'; //set the value
yourinputid.style.backgroundColor = '#yourcolor'; //set the background color请注意,在将颜色值设置为对象时,不应使用颜色值开头的#。
https://stackoverflow.com/questions/50197204
复制相似问题