如何在ajax响应中隐藏按钮

how to hide a button in ajax response?

本文关键字:隐藏 按钮 响应 ajax      更新时间:2023-10-04

我在javascript页面中使用ajax调用。下面是我的ajax调用。。。

$("#txn_post").dialog({
        modal: true,
        title:"Transaction",
        show: 'blind',
        hide: 'blind',
        width: 740,
        height:550,
            });
    $.ajax({
        type: 'POST',
        url: "/pms/txn/newTax",
        success: function (response) {
            /*$("#txn_post").hide();*/
            alert("resp");
            $("#txn_post").html(response);
            alert("after resp");
            //$('#txn_delete_btn').hide();
            //$("#txn_div").dialog("open"); 
            //with out excecuting my above code my dialog works
            /*$("#txn_delete_btn").attr("disabled", false);*/
        }
    });

modal显示,但我尝试了很多方法在modal中隐藏一个按钮。但它不会影响。。。。。。

在我成功使用ajax的过程中,$("#txn_post").html(response);之后的代码并没有被超越。

<div id="txn_post" class="currencydiv" style="width: auto; display: none; min-height: 0px; max-height: none; height: 570px;"></div>

是modal和的div

<input class="pms_void_btn_trnsction txn_delete_btn " id="txn_delete_btn" value="DELETE" onclick="deleteField('${currentTxnNo}');" type="button"></input>是我需要隐藏的删除按钮。

如何对我的ajax成功隐藏上面的按钮?任何帮助都是非常可观的。

试试这个

$("#txn_post").dialog({
    modal: true,
    title:"Transaction",
    show: 'blind',
    hide: 'blind',
    width: 740,
    height:550,
        });
$.ajax({
    type: 'POST',
    url: "/pms/txn/newTax",
    success: function (response) {
        $("#txn_post").html(response);
        $("#txn_post").find('#txn_delete_btn').css('display', 'none');
    }
});

如果仍然有问题,可以通过尝试alert($("#txn_post").attr('id'));alert($("#txn_post").find('#txn_delete_btn').attr('id')); 来确保获得正确的对象