提交看不到返回假;
Submit can't see return false;
我知道我必须将返回 false; 添加到 onsubmit 中调用的函数中(我将其添加到 HTML 中的函数和 onsubmit=" 中)。但它不起作用...按 Enter 或单击提交按钮后页面清新。
JavaScript 生成的表单:
AnswersHTML += "<div><form onsubmit='cheking(this," + a + "," + b + ", this); return false;'><input class='put' type='text' size='40'><input type='submit' value='Проверить'></form>
和功能
function checking(answer, nums, numq, what) {
var usr = answer;
if (isNaN(answer)) {
usr = answer.value;
if (answer.value.length == "") {
usr = "Вы ничего не ввели!"
}
else {
answer = answer.value.toLowerCase();
}
}
if (answer == correct[nums][numq]) {
$(what).parent().parent().append("<br><span class='right'>Ответ: " + usr + "<br>Правильно!</span>").slideDown();
$(what).parent().parent().find(".put").remove();
$("#board").animate({ backgroundColor: '#2ecc71'});
$("#board").animate({ backgroundColor: '#f1c40f'}, 1000);
if (isPhysics[nums][numq]) {
physics++;
$("#presult").text(physics);
}
else {
life++;
$("#lresult").text(life);
}
}
else {
$("#board").animate({ backgroundColor: '#e74c3c'});
$("#board").animate({ backgroundColor: '#f1c40f'}, 1000);
var desciptionToWrong = "<br>" + description[nums][numq];
if (description[nums][numq] == false) {
desciptionToWrong = ""
}
$(what).parent().parent().append("<br><span class='wrong'>Ответ: " + usr + "<br>Неправильно!" + desciptionToWrong + "</span>")
$(what).parent().parent().find(".put").remove();
$(what).remove(".pressenter");
}
return false;
}
对不起,我可能令人作呕的代码
这是整页 https://rawgithub.com/ruslankh/Kurchatovy/master/index.html
功能有问题,因为当我被替换功能只是警报时,它很好
可能是
由于类型。函数调用中的拼写错误会导致错误,调用将转到服务器。
改变
'cheking(this," + a + "," + b + ", this);
自
'checking(this," + a + "," + b + ", this);
您的内联 onclick 有一个拼写错误,您在函数名称中留下了一个 c。此错误可能会在单击处理程序到达 return 语句之前终止它。
试试这个,
AnswersHTML += "<div><form data-a='"+a+"' data-b='"+b+"' class='myform'><input class='put... "
脚本
$(function(){
$(document).on('submit','form.myform',function(){
checking(this, $(this).data('a'), $(this).data('b'), this);
return false;
});
});
相关文章:
- 为什么我在Internet Explorer上看不到html元素
- ajax请求成功,但可以'我看不到我的数据
- 使用jQuery for RSS看不到多个帖子
- 执行此代码时,我看不到警告框
- Javascript 方法看不到对象变量
- 看不到变量
- Phantomjs 看不到 Twitter/Facebook 授权页面
- AS3 XML上的翻页在IE和FIREFOX上看不到
- JavaScript 看不到声明的变量
- 看不到函数外的Javascript变量
- Javascript对象看不到内部函数
- 为什么我的firefox扩展javascript不能访问opener窗口,也看不到window.name
- 从Node.js查询Neo4j时看不到任何回调
- I'我在css中做了一些隐藏的东西,我可以'I don’我现在点击按钮时看不到它
- 我看不到Javascript数组中的图像
- 硒 IDE 1.8.1 警报框:运行测试时看不到警报框
- 在网格PhongMaterial地面和聚光灯上看不到任何带有Colada模型的阴影
- 我正在通过 javascript 向表添加行,但是当我提交页面时,C# 看不到添加的行
- 函数看不到数组中的更改
- 提交看不到返回假;