Jquery Colorpicker 在输入字段中显示值
我使用这个颜色选择器插件:http://www.eyecon.ro/colorpicker/
如何在输入字段中显示起始值?
这是我拥有的 JSFiddle: http://jsfiddle.net/z6Ddy/
I use this colorpicker plugin:http://www.eyecon.ro/colorpicker/
How can i show the start value in the inputfield?
Here is a JSFiddle what i have: http://jsfiddle.net/z6Ddy/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用 attr 设置值
而是使用
Dont use attr to set a value
Instead use
我假设您会将值存储在数据库中以供稍后使用。如果是这样,您将需要使用您选择的任何脚本语言来填充文本输入、显示颜色的 div 背景以及拾色器初始化的颜色属性。
所以基本上,您将检查数据库中是否设置了值,如果是,则将十六进制值插入 div 样式的背景颜色属性、文本输入的 value 属性以及“颜色”颜色选择器初始化的属性。
如果未设置值,您可以设置默认值,例如“#FF0000”。
我更新了小提琴,添加了注释,您可以通过脚本或ajax插入数据,但您的问题是我认为比 jQuery 和颜色选择器更以 PHP 或 .NET 为中心。
I'm going to assume you'll store the value in a database for use later. If so, you'll want to use whatever scripting language of your choice to populate the text input, the background of the div that shows the color, and the color attribute of the Color Picker initialization.
So basically, you'll check to see if there's a value set in the database, and if so, insert the hex value into the background-color property of the div style, and value attribute of the text input, and the "color" property of the color picker initialization.
If no value is set, you can set a default, say "#FF0000."
I updated the fiddle, adding comments where you would insert data via a script or ajax, but your question is more PHP or .NET centric I think than jQuery and Color-picker.