使用jQuery根据输入字段值更新backgroundColor LIVE? [英] Updating backgroundColor LIVE based upon an input field value using jQuery?
问题描述
我正在构建一个小脚本,该脚本根据各种输入字段的值更改页面上的内容和CSS.
I'm building a little script that changes content and css live on the page based upon the values of various input fields.
您可以在这里看到的实时"内容完全可以更改: http://jsfiddle.net/tctc91/eQwsE/
I'm able to change the content "live" absolutely fine as you'll see here: http://jsfiddle.net/tctc91/eQwsE/
我无法使用相同的原理使用css方法进行此操作: http://jsfiddle.net/tctc91/Tnc8p/
I'm not able to get this working with the css method using the same principles though: http://jsfiddle.net/tctc91/Tnc8p/
谢谢!
推荐答案
将第二个bgColor
替换为$(this).val()
.
您已将起始值分配给bgColor
,然后再也不会为其重新分配新值.
You have assigned the starting value to bgColor
, and then you never reassign a new value to it.
jsFiddle .
这篇关于使用jQuery根据输入字段值更新backgroundColor LIVE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!