JavaScript is the next regular way to restore HTML code

Time:2021-10-15

I saw someone in blue today   When I asked this question, I tried to write one. I think the regular replace + function method is very convenient and concise. The code is as follows:


[Ctrl + a full selection note: you need to refresh the page to import external JS]

Recommended Today

Judge whether the information has changed and decide whether it needs to be saved

<!DOCTYPE html> <html> <head lang=”en”> <meta charset=”UTF-8″> <title></title> </head> <body> <div class=”main”> <div class=”baseInfo”> <div class=”form-item” data-belong=”baseInfo” data-type=”input” id=”text1″> <div class=”form-item-caption”>text1:</div> <div class=”form-item-control”> <input type=”text” value=”text1″/> </div> </div> <div class=”form-item” data-belong=”baseInfo” data-type=”select” id=”select1″> <div class=”form-item-caption”>select1:</div> <div class=”form-item-control”> <select name=””> <option value=”1″>1</option> <option value=”2″>2</option> <option value=”3″>3</option> </select> </div> </div> </div> <div class=”otherInfo”> <div class=”form-item” data-belong=”otherInfo” data-type=”input” […]