我试图把条件与jQuery提交按钮,似乎无法使任何工作。如果medLength == 0
那么应该有一个错误消息。没有错误信息,即使medLength
有一个值,提交按钮不起作用。提交按钮有一个图形,所以我不能将其更改为按钮。任何帮助,将不胜感激。JQuery提交按钮的条件
$("#submit").click(function get() {
if (medLength == 0) {
$(".errorStop").css().show;
} else {
$.ajax({
url: "postnew1.php",
type: "POST",
data: {
type: medType,
time: medLength,
length: counter
},
}).success(function (response) {
location.href = "meditate.php";
}).error(function (e) {});
}
});
下面的代码并没有if/else
声明工作:
$("#submit").click(function get() {
$.ajax({
url: "postnew1.php",
type: "POST",
data: {
type: medType,
time: medLength,
length: counter
},
}).success(function (response) {
location.href = "meditate.php";
}).error(function (e) {});
});
什么是medLength? – 2014-11-09 04:16:53
我认为你应该这样做:if(medLength。长度== 0){ – 2014-11-09 04:18:58
您在使用它之前是否曾想过检查'medLength'包含的内容? – 2014-11-09 04:58:35