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

前端 未结 4 881
情深已故
情深已故 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条回答
  •  Happy的楠姐
    2021-01-16 18:42

    That should be:

    $( "#redundant_text_wrapper").text( $( "#redundant_text_wrapper").text().replace('redundantText','') ) ;
    

    Or if you want to replace all occurrences:

    $( "#redundant_text_wrapper").text( $( "#redundant_text_wrapper").text().replace(/redundantText/g,'') ) ;
    

提交回复
热议问题