P
P
Pavel Gonzales2015-10-27 12:29:54
JavaScript
Pavel Gonzales, 2015-10-27 12:29:54

How to implement removing a block after adding it via prepend?

Hello.
There is a filter that adds div blocks with the .disabled class in place, but for some reason I can’t remove it after changing the filters

// скрипт фильтра 
      $(function() {
        var newSelection = "";
        $(".nav-menu").click(function(){
          $(".nav-menu").removeClass("selected");
          $(this).addClass("selected");
          newSelection = $(this).attr("rel");
          $(".country-block").not("."+newSelection).fadeTo(800, 0.33).prepend('<div class="disabled"></div>');
          $("."+newSelection).fadeTo(800, 1).remove('.disabled');
          $(".all-flavors").fadeTo(600, 1);

          });

        });


.disabled {
  background: rgba(20,26,31,0.9);
  cursor: default;
  width: 100%;
  height: 100%;
  z-index: 99999;
  position: absolute;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Loginov, 2015-10-27
@pavelgonzales

$("."+newSelection).fadeTo(800, 1).remove('.disabled');

Change to:
$("."+newSelection).fadeTo(800, 1);
$('.disabled').remove();

Although it is better to completely rewrite the code, but that's up to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question