createDocumentFragment() used in a for loop

前端 未结 3 1015
抹茶落季
抹茶落季 2021-01-26 09:15

Is createDocumentFragment() doing anything in the code below?

I\'m trying to adapt this code. I\'m not sure how it works and the for loo

3条回答
  •  深忆病人
    2021-01-26 09:43

    It looks to me like the fragment is being used as a way to store the original dom of results_table. The for loop then makes changes to the results_table. Once that is done, the fragment (containing the original table) is appended to the end of results_table.

    It's basically putting the new search results at the top of the table and moving the the old results to the bottom, so both the fragment and the for loop do something.

提交回复
热议问题