jquery text().replace('','') not working

前端 未结 4 851
情深已故
情深已故 2021-01-16 18:33

Hi I am trying for hours now to remove a text string again after I have appended it.

I have a script that handles an accordion and I have some redundancy in text in

4条回答
  •  粉色の甜心
    2021-01-16 19:02

    Ok, I tried a different approach now:

    var redundantText = " text text text Contact Me text text text";
    
    $('#collapse_1').on('show.bs.collapse', function() {
      $(".dropdown_collapse_1").addClass("dropdown-indicator");
      $(".dropdown_collapse_1").removeClass("dropdown-collapsed");
      $("#redundant_text_wrapper").after(redundantText);
    });
    $('#collapse_1').on('hide.bs.collapse', function() {
      $(".dropdown_collapse_1").addClass("dropdown-collapsed");
      $(".dropdown_collapse_1").removeClass("dropdown-indicator");
       $('#redundantText_wrapper').remove();
    }); 
    

    So basically I use 'after' instead of 'append' and put the text into a span with ID. Now I can use $('#ID').remove(); to get rid of it on closing the tab.

提交回复
热议问题