Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update display color from input[type=color]

Hi,

I want to change the value attribute of a <input type="color"> element. It works if I clicked it, but the display color of the input button is not changing. If I change the color manually from beginning, it works (but I have to change it on runtime).

Watch this JSFiddle to get what I mean: http://jsfiddle.net/5u544/

Thanks and greetings Mat

Edit: Like in the comments below, the problem was the difference between object attributes and properties. Credits to @Navin for this ;)

like image 906
schlenger Avatar asked Aug 04 '14 10:08

schlenger


1 Answers

you can use the .val() property to set the value like this

$("#test").val("#ff66ff");

JSFiddle

like image 157
Navin Avatar answered Nov 15 '22 12:11

Navin