单击它时我有一个按钮开始计数,所以现在我希望它在再次单击时停止计数。所以我可以点击任何其他按钮,并且该按钮必须与第一个按钮完全一样,我们将不胜感激。
这就是按钮的创建方式
function createButtons(tbID, tbClass, tbType, tbValue, onClick) {
return '\n<input '
+ (tbID ? ' id=\'' + tbID + '\'' : '')
+ (tbClass ? ' class=\'' + tbClass + '\'' : '')
+ (tbType ? ' type=\'' + tbType + '\'' : '')
+ (tbValue ? ' value=\'' + tbValue + '\'' : '')
+ (onClick ? ' onclick=\'toggle(this);' + onClick + '\'' : '')
+ '>';
}
function (i, item) {
newContent += createButtons("tb" + item.CommonCable, null, "submit", item.CommonCable, toggle);
});
以下代码正在计算按钮单击的时间。并将其显示在 HTML 页面中。功能切换(ths){
$(ths).toggleClass("btnColor");
$("#tb").toggleClass("btnColorR");
var clicked = $(ths).val();
$("#setCount").html(" DOWNTIME TYPE : " + clicked + " MINUTES : " + minutes + " SECONDS : " + count );
count = count + 1;
if (count % 60 == 0) {
minutes += 1;
count = 0;
}
timer = setTimeout("toggle()", 1000);
}