Jquery Div opening and closing

1. I need to do a full text review.. Functions that can be put away

at the beginning, I will run a method show (), to show only part of the text, and then the session will show all the text, but I don"t know how to put away this method. Please be busy in two directions

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

Introduction_html+="<div class="doc_formation">"                                    
$.each(this.board,function(){
Introduction_html+="<br><span class ="doc_title">"+this.title+"</span><br>"
Introduction_html+="<span class="doc_connent">"+this.content+"</span>"
});
Introduction_html+="<a class="back" href="javascript: void(0)" style="display:none" onclick=""></a>"
Introduction_html+="</div>"

   function show(){
   $(".doc_formation").each(function(){
   var text=$(this).html();
    
    if($(this).text().length>lng){
         $(this).text($(this).text().substring(0,lng));
            $(this).html($(this).html()+"..."+"<a href="javascript: void(0)"> </a>");
    }

    $(this).find("a").click(function(){
        $(this).parent().html(text);
       $(".back").css("display","block");
    })
})

}

I hope to be able to press put away, change back to show only part of the text, and then click on the full text again. The mistake I encounter now is to click on a full text page. After pressing put away, the full text of other posts will not be available.

Mar.29,2021

scanned the code, probably the error is: you gave to read the full text , put away bound the event, and then you used html () you replaced the document element, and the event will be lost, you need to use event delegation to solve, hope to adopt!

Menu