これは私が気づいた非常に奇妙なバグです。イベントを使用して、.focus()
トリガー時にdivを別のdivに追加します。コードは問題なく、正常に動作しますが、タブを切り替えて (別のサイトを開くことを意味します)、イベントを使用したサイトに戻ると.focus
、結果が重複します。コードを見たい場合は教えてください。ただし、これは単純なイベント呼び出しであり、特別なことは何もありません。コードは次のとおりです。
<div id="song">
<input type="text" id="post_title" name="title" value="Artist - Song" /><br />
</div>
var songSuggestion = '<div id="titleSuggest" style="width:270px; background:#37819d; color:white; margin:0 auto; ">Try this!</div>';
$('#post_title').focus(function(event){
$(this).parent().append(songSuggestion);
});
$('#post_title').blur(function(){
$(this).parent().find('#titleSuggest').remove();
});
編集: これはクロムでのみ発生し、Firefox では発生しません!