【问题标题】:calling jquery replace content does not works when inside of function在函数内部调用 jquery 替换内容不起作用
【发布时间】:2013-05-14 05:01:16
【问题描述】:

所以我想:http://jsfiddle.net/LdeGC/1/

            if ($('.ui-droppable').find('span.closer').length == $('.ui-droppable').length) {
                alert('Listo ahora puedes simularlo');
                //if target is filled
                    $(".status1").replaceWith('<i class="icon-check"></i> Listo ahora puedes simularlo'); //update status
                //put composition into params
            } else {
                $(".status1").replaceWith('<i class="icon-edit"></i> Sigue');
            }

警报有效,但 if 中的 jquery replaceWith 无效,我该如何解决?

【问题讨论】:

  • 这是因为在第一次执行时status1 元素被删除了,所以在第二次执行中$(".status1") 不会返回任何东西

标签: jquery draggable droppable


【解决方案1】:

尝试使用html 而不是replaceWith

试试下面

 if ($('.ui-droppable').find('span.closer').length == $('.ui-droppable').length) {
            alert('Listo ahora puedes simularlo');
            //if target is filled
                $(".status1").html('<i class="icon-check"></i> Listo ahora puedes simularlo'); //update status
            //put composition into params
        } else {
            $(".status1").html('<i class="icon-edit"></i> Sigue');
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-30
    • 1970-01-01
    相关资源
    最近更新 更多