真的在這裏簡單的代碼掙扎。我正在檢查#setactionsuccess部分是否存在,如果不是,我想創建它並將其前置到容器中。第一部分工作順利,但它永遠不會去'其他'(和條件滿足 - 我三重檢查)。任何幫助不勝感激。if/else in jquery
if ($('#setactionsuccess')){
var currenttime = new Date();
$('#setactionsuccess').empty();
$('#setactionsuccess').html('<h2>Set successfully deleted</h2><p>Set was successfully removed from this Edition on '+currenttime+'</p>');
} else {
console.log('here');
var string = '<section class="successful" id="setactionsuccess"><h2>Set successfully deleted</h2><p>Set was successfully removed from this Edition on '+currenttime+'</p></section>';
console.log(string);
$('#currentsets').prepend(string);
}
感謝您的詳細解釋。這是有用的知道 – boszlo 2012-08-10 13:12:48