Replacement of the basket in best personal Finance?

There is a menu fixed when scrolling the page. In the block there is also a search. When you scroll down, the search is replaced by a basket. If you scroll back up - appears again search, but it no longer works! How can I fix it? Here is a script with fixing and replacement of components

var $menu = $(".vnesh-plashka"); 
var $cart = $("#cart"), 
$search = $("#search"); 

if ( $(this).scrollTop() > 140 && $menu.hasClass("default") ){ 
} else if($(this).scrollTop() <= 140 && $menu.hasClass("fixed")) { 
$(".vnesh-plashka #cart").replaceWith($search); 

July 8th 19 at 11:44
1 answer
July 8th 19 at 11:46
Probably the problem is in replaceWith. Just try to hide in hide()

Find more questions by tags jQueryOpenCart