• 工作整理日志


    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(); });

    });

  • 相关阅读:
    字符函数和字符串函数的使用及模拟实现(上)
    基于GAN的自动提取混凝土损伤特征方法
    DAIDAI.IO-让DAO重新定义 Web3 NFT平台
    UG7.5三四五轴编程+后处理讲解视频教程
    可重复执行SQL语句|建表、插入默认值、增加字段、删除字段、修改字段可重复执行SQL语句|oracle|mysql
    【python之父】:从他的经历中我又重拾对编程的热爱,程序员也不是一直写代码就没有出路
    SpringCloud搭建微服务之Bus消息总线
    什么是On-die Termination(ODT,片上端接)
    【Python零基础入门篇 · 37】:正则基础
    动态内存精讲
  • 原文地址:https://blog.csdn.net/goodyatou/article/details/127877741