通过 Javascript / Jquery 更改 JSColor 值
Changing JSColor value via Javascript / Jquery
如何通过javascript设置输入文本框(JSColorclass)的值?我想更改背景颜色和输入值(通过 Javascript 命令,或 Jquery。足够好)。
谢谢。
使用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
请注意,将颜色值设置为对象时,不应在颜色值的开头使用#。
如何通过javascript设置输入文本框(JSColorclass)的值?我想更改背景颜色和输入值(通过 Javascript 命令,或 Jquery。足够好)。
谢谢。
使用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
请注意,将颜色值设置为对象时,不应在颜色值的开头使用#。