JavaScript. It's incorrect to replace one class with another.



  • There are a few blocks containing one-time calendars and a button to drop, it's picked up on the click at the date (i.e. changing class at the cell), but the "shoot" button doesn't drop the dates chosen. I mean, they don't change the changed class to the reference class. Originally, a column with a date has such a class:

    td.cal-av.cal-selectable
    

    .cal-av indicates the date Not selected, after she's clicked, the cell class changes to:

    td.cal-nc.cal-selectable
    

    This replacement is in the modular code and has never found where... ♪ There's a button outside the calendar..acbf-reset-both.form-resetthe click on which the class should change back. Suggested the following options:

    jQuery(function ($) {
    $(".acbf-reset-both.form-reset").click(function() {
    
         $(".cal-nc").addClass('cal-av');
         $(".cal-nc.cal-av").removeClass('cal-nc');     
    

    });
    });

    and

    jQuery(function ($) {
    $(".acbf-reset-both.form-reset").click(function() {

         $(".cal-selectable").removeClass('cal-nc');
         $(".cal-selectable").addClass('cal-av');       
    

    });
    });

    but in both cases class cal-av signed at the end, i.e. instead of returning to the reference state td.cal-av.cal-selectable This is how it works:

    td.cal-selectable.cal-av

    I know there's another switch Class, but there's nothing he wants me to do. ♪ ♪

    Before pressurizing the button, drop (seen - selected dates, green - free): введите сюда описание изображения

    When you press the button, drop: введите сюда описание изображения

    ...as can be seen (listened) the class has been written not where it is, but below (green) it should be.



  • Class rules don't matter.

    But if you really need to,

    $(".cal-nc").attr('class', 'cal-nc cal-selectable')
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2