jQuery append only once
问题 So I have this: jQuery("document").ready(function($){ var nav = $('#nav'); var logo = '<img src="img/logo.png" />'; $(window).scroll(function () { if ($(this).scrollTop() > 136) { nav.addClass("nav-f"); nav.append(logo); } else { nav.removeClass("nav-f"); nav.remove(logo); } }); }); When scrolling I'm trying to make the navigation to be fixed, which works, but I also want to add a tag with the logo image in the #nav div, which also works but it appends on every scroll so when scrolling I get