我做了我自己的,自制的,有/無功能,但它不起作用。jQuery確認/取消自制功能不起作用
下面是函數:
function CoverAndShow (title, text, type) {
if (type == "confirm") {
$("body").append("<div class='msg'><h3>" + title + "</h3><p>" + text + "</p><input class='ok' type='button' value='OK' /><input type='button' class='cancel' value='Cancel' /></div>");
}
$(".ok").click(function() {
return true;
});
$(".cancel").click(function() {
return false;
});
}
這裏是我點擊「確定」,在功能代碼:
$("#ask").click(function() {
if (CoverAndShow("Title","Should I operate?", "confirm") == true) {
alert("true");
}
這將無法正常工作,並且不會返回任何東西。
幫助將不勝感激!
哪部分不能工作? – 2014-09-21 09:06:19
它應該是===真 – 2014-09-21 09:07:38
==應該可以,只要你不需要檢查數據類型,不是嗎? – 2014-09-21 09:09:38