【问题标题】:Jquery TimeCircles Value when stoppedJquery TimeCircles 停止时的值
【发布时间】:2014-04-21 16:17:32
【问题描述】:

这是我目前所拥有的。我希望能够从提交按钮中删除隐藏的类,然后将计时器值复制到隐藏的文本字段中。任何帮助,将不胜感激。

jQuery(document).ready(function($) {
  $(".timer").TimeCircles({
    "start": false,
    "animation": "smooth",
    "bg_width": 1.2,
    "fg_width": 0.1,
    "circle_bg_color": "#60686F",
    "time": {
        "Days": {
            "text": "Days",
            "color": "#FFCC66",
            "show": false
        },
        "Hours": {
            "text": "Hours",
            "color": "#99CCFF",
            "show": false
        },
        "Minutes": {
            "text": "Minutes",
            "color": "#BBFFBB",
            "show": true
        },
        "Seconds": {
            "text": "Seconds",
            "color": "#FF9999",
            "show": true
        }
    }
  });
  $(".stop").click(function(){
    $(".timer.stopwatch").TimeCircles().stop();
  });
  $(".start").click(function(){
    $(".timer.stopwatch").TimeCircles().start();
    //remove class hidden on submit button
    //copy timer value to text field

  });
  //$(".restart").click(function(){
  //    $(".timer.stopwatch").TimeCircles().restart();
  //}); 
});

【问题讨论】:

  • 欢迎来到 SO。目前尚不清楚你要做什么......你什么时候想从按钮中删除类......? .TimeCircles 是什么?你在使用插件..?请使用适当的信息更新问题...
  • TimeCircles 是一个 Jquery 计时器/秒表插件。作者的回答正是我想要的。谢谢。

标签: jquery return-value


【解决方案1】:

如果您可以包含您的 html,它可能会有所帮助,但是:

可以使用以下方法从“提交按钮”中删除一个类:

$("[type=submit]").removeClass('hidden');

您可以使用以下方式获取剩余时间:

var timeleft = $(".timer.stopwatch").TimeCircles().getTime();

您可以使用以下方法将该值放入文本框中:

$("input#timervalue").val(timeleft);

【讨论】:

  • 这是我自己环顾四周后得到的。不过感谢您的回复。
【解决方案2】:

谢谢你,维姆。这与我得到的答案几乎相同。这就是我最终得到的。

jQuery(document).ready(function($) {

$(".timer").TimeCircles({
    "start": false,
    "animation": "smooth",
    "bg_width": 1.2,
    "fg_width": 0.1,
    "circle_bg_color": "#60686F",
    "time": {
        "Days": {
            "text": "Days",
            "color": "#FFCC66",
            "show": false
        },
        "Hours": {
            "text": "Hours",
            "color": "#99CCFF",
            "show": false
        },
        "Minutes": {
            "text": "Minutes",
            "color": "#BBFFBB",
            "show": true
        },
        "Seconds": {
            "text": "Seconds",
            "color": "#FF9999",
            "show": true
        }
    }
});
$(".stop").click(function(){
    $(".timer.stopwatch").TimeCircles().stop();
    $("#activitysubmit").prop("disabled",false);
    var activity_time = $(".timer.stopwatch").TimeCircles().getTime();
    $("#activity_time").val(Math.abs(activity_time));
    //alert ($(".timer.stopwatch").TimeCircles().getTime());

});
$(".start").click(function(){
    $(".timer.stopwatch").TimeCircles().start();
    $("#activitysubmit").prop("disabled",true);

});
//$(".restart").click(function(){
//  $(".timer.stopwatch").TimeCircles().restart();
//}); 

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多