有没有办法从表单字段在 CSS 文件上输入值?
Is there a way to input values on a CSS file from a Form Field?
例如,
我想要一个显示 'Background Color' 的表单字段,当我在该字段上输入 HEX 颜色时,它知道将值放在背景颜色下:[value from form];
我很难在网上找到与此相关的文章,因此非常感谢您的帮助。
谢谢
也许可以看看使用像下面这样在模糊上运行的函数。因此,在表单中您需要输入 #000 或类似内容,然后当您点击字段外时,背景颜色将会改变。
<form action="#">
<input type="text" placeholder="Enter hex">
</form>
<script>
$(document).ready(function() {
$('form input').on('blur', function(){
$(this).css('background-color', $(this).val());
});
});
</script>
例如, 我想要一个显示 'Background Color' 的表单字段,当我在该字段上输入 HEX 颜色时,它知道将值放在背景颜色下:[value from form];
我很难在网上找到与此相关的文章,因此非常感谢您的帮助。
谢谢
也许可以看看使用像下面这样在模糊上运行的函数。因此,在表单中您需要输入 #000 或类似内容,然后当您点击字段外时,背景颜色将会改变。
<form action="#">
<input type="text" placeholder="Enter hex">
</form>
<script>
$(document).ready(function() {
$('form input').on('blur', function(){
$(this).css('background-color', $(this).val());
});
});
</script>