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> Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/218903-javascript-andor-jquery-help/#findComment-1135483 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.