简体   繁体   中英

Jquery change color on click - knob knob

I am using jquery knob knob on my site to create some nice visuals. I wish to change the color using a click event. I have provided a simplified fiddle of what I am trying to achieve. I have been trying for several hours and now have to ask for help

DEMO http://jsfiddle.net/JW2gP/62/

HTML

<input type='text' id='dial' value='0' />

<a id="chgColor" href="#">Change color on click</a>

jQuery

$(function () {
    $('#dial').knob({
        min: '0',
        max: '25000',
        fgColor: '#f00'
    });
    $('#dial').val(10927).trigger('change');
});

$('#chgColor').click(function(e){
    e.preventDefault();
    $('#dial').knob({
        min: '0',
        max: '25000',
        fgColor: '#000'
    }); 
});

VIOLA (and here in fiddle, finally found my creds: http://jsfiddle.net/bhilleli/JW2gP/66/ )

$(function () {
    $('#dial').knob({
       min: '0',
       max: '25000',
       fgColor: '#f00'
    });
    $('#dial').val(10927).trigger('change');
});

$('#chgColor').click(function(e){
   e.preventDefault();

   $('#dial').trigger(
     'configure',
      {
        min: '0',
        max: '25000',
        "fgColor":"#001"
    }
);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM