dadamssg Posted November 17, 2010 Share Posted November 17, 2010 I have a color picker on my page that puts the hex value in an input box. I'm not familiar with jquery or javascript in general. I would like to be able to take the hex value and use it in updating a style of a div...say the border color for example. Something like this...but this isn't working.... any help would be awesome! <input type="text" id="colorfield1" onFocus="ddcolorposter.echocolor(this, 'colorbox1')"> <div id="colorbox1" class="colorbox"></div> <br><br> <div id="testbox"> Some Text </div> <script> $("#colorfield1").keyup(function () { var value = $(this).val(); $("#testbox").style.border="1px solid "+ value; }).keyup(); </script> Link to comment https://forums.phpfreaks.com/topic/218903-javascript-andor-jquery-help/ Share on other sites More sharing options...
Adam Posted November 17, 2010 Share Posted November 17, 2010 You're mixing JavaScript with jQuery here: var value = $(this).val(); $("#testbox").style.border="1px solid "+ value; The style property doesn't exist within jQuery, you need to use the .css(propertyName, value) method. Link to comment https://forums.phpfreaks.com/topic/218903-javascript-andor-jquery-help/#findComment-1135483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.