Js dynamic delete div element basic ideas and implementation code

  • 2020-03-30 02:54:05
  • OfStack

Those HTML elements are generated dynamically by Ajax because the results of a user lookup are loaded and displayed dynamically. When the user opens the search interface, there are users recommended by the system, and when the user searches by the conditions, the search results are dynamically loaded and displayed. So consider using js. This for loop simply removes the existing form. The new form object is then dynamically generated based on the data from the Ajax request. It is important to note that j variables from big to small cycle, otherwise, delete the div elements can cause serchResultLenth = serchResult. After the children. The length; Length change (this problem took a long time to solve, remember)
for(var j=serchResultLenth-1;j>=0;j--){ 
var serchChild=document.getElementById(serchResult.children[j].id); 

Related articles: