If语句在javascript中不工作,语法是否正确?

if statement not working in javascript,is the syntax correct?

本文关键字:是否 语法 工作 语句 javascript If      更新时间:2023-09-26

这个js脚本不适合我,我做错了什么?语法正确吗?

$(document).on("click","."+deletebutton,function(){
    var id = $(this).attr("id");
    if(id){
            if(p_name!= name){
        if(confirm("say something"))
            ajax("rid="+id,"del");
            }
            else{window.alert(say something);
            }
    }
});

这是你的代码:

$(document).on("click", "." + deletebutton, function() {
    var id = $(this).attr("id");
    if(id)
    {
        if(p_name != name)
        {
            if(confirm("say something")) ajax("rid=" + id, "del");
        }
        else
            window.alert(say something);
    }
});

没有引号:window.alert(say something);。用alert("say something");代替。

deletebutton, name, p_name, ajax是否有定义?