• 工作整理日志


    JS动态添加元素后事件不起作用失效

    解决方案:

    $("#table").on("click","td",function(){ alert($(this).attr("id")); });

    js给 html:

    1.解决赋值问题。
    在前端使用Js给ASP.NET服务器控件   visilbe 为false的也获取不到

        $("#btnaddbaby").click(function () {
            var monitorid = $(this).attr("id");
            console.log($(this).attr("id"));
     
        });

    ddl 动态添加options

      var htmlInfo = "";
                                //ddlbaby
                                $.each(obj, function (n, value) {
                                    htmlInfo += " ";
                                });
                                $("#ddlbaby").append(htmlInfo);


    $(function () {
        //获得绑定数据
        $.ajax({
            type: "POST",
            url: "/ajax/BabyHandler.ashx",
            dataType: "json",
            data: {
                act: 'getlist'
            },
         

     success: function (e) {
                if (e.ResultCode == 1) {
                    var obj = e.lstBaby;
                    var htmlInfo = "";
                    htmlInfo += `

    共有${obj.length}个宝宝
    `;
                    htmlInfo += `    
    `;
                    $.each(obj, function (n, value) {

                        htmlInfo += `      

    `;
                        htmlInfo += `        
    房间:${value.RoomName},妈妈:${value.MotherName}
    `;
                        htmlInfo += `          
    ${value.BabyName}(ID${value.BabyKey})
    `;
                        htmlInfo += `      
    `;

                    });
                    htmlInfo += `      

    `;
                    htmlInfo += `      
    `;
                    htmlInfo += `    
    `;
                    htmlInfo += `  
    `;
                    $("#babycontent").html(htmlInfo);
                } else {
                    alert(e.ResultMessage);
                }

        });


     

        $("#btnaddbaby").click(function () {
            var monitorid = $(this).attr("id");
            console.log($(this).attr("id"));
            $(".showpop").show();
            $(".bindbaby").hide();
            $(".showbindbabywrap").hide();
            $(".addbabywrap").show();
        });
        $("._monitorempty").click(function () {
            var monitorid = $(this).attr("id");
            console.log($(this).attr("id"));
            $(".showpop").show();
            $(".bindbaby").show(); $(".addbabywrap").hide();
            $(".showbindbabywrap").hide();
            $(".showpop_manitor_name").text(monitorid);
        });

        $("._monitorbaby").click(function () {
            var monitorid = $(this).attr("id");
            console.log($(this).attr("id"));
            $(".showpop").show();
            $(".bindbaby").hide(); $(".addbabywrap").hide();
            $(".showbindbabywrap").show();
            $(".showpop_manitor_name").text(monitorid);
        });


        $(".close").click(function () { $(".showpop").hide(); });

    });

  • 相关阅读:
    jQuery绑定事件bind
    动态代理模式
    nginx 编译使用 nginx_upstream_check_module
    如何创建网站才能满足用户需求?
    【C++笔试强训】第二十四天
    【Verilog】HDLBits题解——Circuits/Sequential Logic/Latches and Flip-Flops
    办公自动化解决方案——DocuWare Cloud 将应用程序和流程迁移到云端的完整的解决方案
    Java学习07——原码、反码和补码
    Flutter——最详细数组List使用教程
    C语言--每日五道选择题--Day11
  • 原文地址:https://blog.csdn.net/goodyatou/article/details/127877741