如何获取jquery对象的值

时间:2014-05-05 12:13:16

标签: javascript jquery

我正在使用这个jquery插件。我想获取选定的时间值并将其保存到页面上的某些输入中。我怎样才能做到这一点?

插件和代码在这里:

http://jsfiddle.net/weareoutman/YkvK9/

var input = $('#input-a');
input.clockpicker({
    autoclose: true
});

// Manual operations
$('#button-a').click(function(e){
    // Have to stop propagation here
    e.stopPropagation();
    input.clockpicker('show')
            .clockpicker('toggleView', 'minutes');
});
$('#button-b').click(function(e){
    // Have to stop propagation here
    e.stopPropagation();
    input.clockpicker('show')
            .clockpicker('toggleView', 'hours');
});

2 个答案:

答案 0 :(得分:2)

您可以使用.val()

来获取它
 $('#input-a').val();

更新有关更改的输入:

$('.container').clockpicker().find('input').change(function(){
  $('#new').val(this.value);
});

<强> Working Demo

答案 1 :(得分:0)

 $('#input-a').val();

http://jsfiddle.net/YkvK9/4/

参见演示