javascript - Jquery change color on click - knob knob - Stack Overflow

I am using jquery knob knob on my site to create some nice visuals. I wish to change the color using a

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 /

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'
    }); 
});

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/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'
    }); 
});
Share Improve this question asked Feb 21, 2014 at 22:57 user1320260user1320260 1
  • 1 What is it exactly what you want to do? The left part of the circle changes when I click it. Or do you want other functionality? – user2609980 Commented Feb 21, 2014 at 23:11
Add a ment  | 

1 Answer 1

Reset to default 6

VIOLA (and here in fiddle, finally found my creds: http://jsfiddle/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"
    }
);
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745622222a4636588.html

相关推荐

  • javascript - Jquery change color on click - knob knob - Stack Overflow

    I am using jquery knob knob on my site to create some nice visuals. I wish to change the color using a

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信