如何使用 PHP 获取 jQuery ID 值
how to get the jquery id value using php?
<script>
function startTimer(duration, display) {
var timer = duration,
minutes, seconds;
interval = setInterval(function() {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.text(minutes + ":" + seconds);
if (--timer < 0) {
alert("Time has ended");
$("#registration-form").submit()
clearInterval(interval);
}
}, 1000);
return new Date();
}
jQuery(function($) {
s = 10;
var Minutes = 60 * s,
display = $('#time');
var startDate = startTimer(Minutes, display);
$('button').click(function() {
var now = new Date();
var seconds = (now.getTime() - startDate.getTime()) / 1000;
$('#runtimes').append('<p>' + seconds + '</p>');
})
});
</script>
<div class="col-md-4">
<div class="test">Time Left <span id="time"></span>min</div>
</div>
<form name="frmRegistration" id="registration-form" method="post" action="index1.php">
<div id="runtimes" name="runtime"></div>
<button>Get run time</button>
</form>
https://jsfiddle.net/aruncool/vj84mc40/在链接中显示按钮单击时已运行时间的值,我需要通过 POST 传递div id 值并将其放入另一个页面并将该值插入数据库,但它没有通过帖子传递值帮助我如何获取div id 值
您可以在表单中添加隐藏的输入,并在需要时更新其值。
.HTML
<input type="hidden" id="valueoftime" name="valueoftime">
杰奎里
$('button').click(
var now = new Date();
var seconds = (now.getTime() - startDate.getTime()) / 1000;
$('#runtimes').append('<p>' + seconds + '</p>');
//Update input val
$("#valueoftime").val(seconds);
})
相关文章:
- 是否有一个JS/jQuery函数可以获取某个类的每个元素的ID
- 获取打开jquery对话框的button的id
- jQuery mobile not going through ID
- 如何将li类更改为li id's在Jquery中
- 如何使用jQuery迭代id名称的变体(如idname1、idname2)
- 获取不带Id JQuery的复选框值
- 从ID Jquery类获取返回值时出现问题
- attr() 不会更改 id - jquery
- 通过 ID jquery 限制文本区域字符
- 获取选定的行id jquery数据表行选择
- 如何在asp.net mvc中向Action方法发布简单ID(jquery-ajax)
- 添加文本到Javascript Span id jquery
- 动态获取控件ID - JQuery
- 验证选择字段取决于id jquery
- Increment id jquery
- 使用id jquery中的空格
- 根据HTML表的ID jQuery/javaScript对数据进行排序
- 以引号结束id - jquery
- 当draggable被拖放到可拖放区域时添加ID - jQuery Draggables
- 表格ID &jQuery中的名称