注册 登录
编程论坛 jQuery论坛

有大佬帮忙看看么?

a909919948 发布于 2021-12-02 09:52, 1226 次点击
我用jq的克隆函数,把渲染的数据克隆了下来,然后更改克隆之后的CSS样式,发现总有一个DIV的样式没有改变,该怎么解决啊?
程序代码:
$(".call>.noCall").hide();
            $(".zwwa5 call>.shanchu").hide();
            var existsItemId = [];

            $(".noCall").on("click", function () {
                var parent = $(this).parent();
                if (existsItemId.indexOf(parent.data("id")) === -1) {
                    i++;

                    $("#useritem2>li").css({
                            "background-color": "#1e316a",
                            "position": "relative",
                            "height": "56px",

                        }
                    );

                    $("#useritem2>div").css({

                        "position": "relative",


                        "top": "-11px",
                        "left": "33px"
                    });
                    $("#useritem2>li>.a2").css({
                        "position": "relative",
                        "top": "17px"



                    });
                    existsItemId.push(parent.data("id"));
                    var cloneNode = parent.clone(true);
                    cloneNode.find(".noCall").attr('class', 'zwwa3')
                    cloneNode.find(".blank").attr('class', 'blink')
                    cloneNode.find(".zwwa3>img").remove();
                    // $.parser.parse("#useritem2>noCall");
                    $('.zwwa3').replaceWith("<div id='close' style=\"height: 14px;width: 14px;position: relative;top: 6px;left: 23px;\"><img  src='/res/Conduct/close.png' style=\"position: relative;top: -11px;left: 33px;\"></div>");
                    $('.blink').replaceWith("<div style='position: relative;top:-30px'><img src='/res/Conduct/video.png' ></div>");

                    // $("#useritem2>li").css({
                    // "background-color":"#1e316a",
                    //     "position":"relative",
                    //     "height": "56px",
                    //
                    //     }
                    // );
                    // $("#useritem2>div").css({
                    //
                    //     "position":"relative",
                    //
                    //
                    //     "top":"-11px",
                    //     "left":"33px"
                    // });
                    // $("#useritem2>p").css({
                    //
                    //  "position":"absolute",
                    //
                    //     "width":"100%",
                    //     "top":"33px",
                    // });


                    $("#useritem2").append(cloneNode);

                } else {
                    // alert("已经添加过了!")
                }

            });
            $('#useritem2').on('click', '#close', function() {
                // this 指向委托的对象 li
                $("#useritem2>.call").remove();

                // 找到父级 ul#wrap

            });
0 回复
1