2013-05-14 65 views
1

所以我試着去:http://jsfiddle.net/LdeGC/1/調用jQuery的替代物不工作時的函數內部

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

警報的作品,但裏面的jQuery的replaceWith如果沒有,我怎麼能解決這個問題?

+0

這是因爲第一次執行時'status1'元素被移除,以便在第二次執行'$(」狀態1" )'不會返回任何東西 – 2013-05-14 05:16:15

回答

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