Jump to content

javascript and/or jquery help


dadamssg

Recommended Posts

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.... :confused: 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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.