JavaScript上的onClick =" return func();;;;在第一个元素之后停止工作
<button onclick="return validateEdit();" class="btn btn-primary submit-btn">Submit</button>
function validateEdit() {
var name = document.getElementById("sftName").value;
aler("name")
var startTime = document.getElementById("startTimeEdit").value;
aler("start time")
}
该函数执行第一个警报,并且不显示第二个警报。我也在使用:
$('#edit_shift').on('show.bs.modal', function (event) {
var anchor = $(event.relatedTarget) // Button that triggered the modal
var id = anchor.data('whatever')
var from = anchor.data('fromtime')
var modal = $(this)
$("#sftName").attr("value", name);
$("#startTimeEdit").attr("value", from);
在另一种形式中工作正常。
编辑:有值和没有值的开始时间在这两种情况下都不起作用。
我对 javascript 完全是零。
<button onclick="return validateEdit();" class="btn btn-primary submit-btn">Submit</button>
function validateEdit() {
var name = document.getElementById("sftName").value;
aler("name")
var startTime = document.getElementById("startTimeEdit").value;
aler("start time")
}
The function execute first alert and don't show second aler.I am using also:
$('#edit_shift').on('show.bs.modal', function (event) {
var anchor = $(event.relatedTarget) // Button that triggered the modal
var id = anchor.data('whatever')
var from = anchor.data('fromtime')
var modal = $(this)
$("#sftName").attr("value", name);
$("#startTimeEdit").attr("value", from);
In the another form is working fine.
Edit: start time with value and without value is not working in both cases.
I am full zero at javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一些拼写错误。确保代码中是alert,而不是aler。此外,您发布的 html 内容只有按钮,而您尝试获取 id sftName 和 startTimeEdit 的两个元素,请确保这些元素存在于您的代码中。
为了更好地理解,您可以在 codepen 上重新创建上述问题。
There are some typo error. Make sure its alert in your code and not aler. Also html content you posted having only button, whereas you are trying to fetch two elements with id sftName and startTimeEdit, make sure those elements are there in your code.
For better understanding can you recreate above issue on codepen.