j3velez Posted April 3, 2013 Share Posted April 3, 2013 I need to append the shopping cart to a div (sliding_header) that is created when scroll down, but I dont want to populate that div with "append" function because the amount of symbols (+' ') I should use to make it works . is there another way to populate and/or create the div? $(function() { var sliding_header = $('<div>').addClass('sliding_header_bg '); sliding_header.append('<div id="header_cart_container">' +'<div id="shopping_cart">' +' <div id="top_cart">' +' <span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties02}</span>' +' <span class="ajax_cart_no_product{if $cart_qties > 0} hidden{/if}">{l s='(0)' mod='blockuserinfo'}</span>' +' </div>' +'</div>' +'</div>'); $(window).scroll(function() { if($(this).scrollTop() > 100) { sliding_header.appendTo($('body')).fadeIn('fast'); } else { $(sliding_header).fadeOut(function(){ $(this).remove() }); } }); }); Link to comment Share on other sites More sharing options...
Recommended Posts