Is there any sort of way, framework or plugin where I can get the default value of a div after it has been changed from the dom/devTool? For example if <div class="div-1">Alex</div>
and I use dom/DevTool to change it to <div class="div-1">Megan</div>
, when I want to get the text of that div how do I get Alex instead of Megan. I am doing ajax so I need the default data instead of the changed data.
Asked
Active
Viewed 56 times
0

Sang Nguyen
- 167
- 1
- 9
-
I don't think so, you may prefer to use a data attribute – Mister Jojo Feb 19 '21 at 01:07
-
your question is too broad. it could be done in a number of ways. if the value is from php, could you save it in a session? or make add a data attribute with the original value and use that – Kevin Feb 19 '21 at 01:08
-
@Kevin couldn't that still be changed with the development tool? – Sang Nguyen Feb 19 '21 at 01:15
-
Google for Mutation Observer. – Louys Patrice Bessette Feb 19 '21 at 01:15
-
@SangNguyen you mean the data attribute? yes of course, in PHP no, you can't edit the value from dev tools. – Kevin Feb 19 '21 at 01:17
-
Strong duplicate possibility: https://stackoverflow.com/questions/2844565/is-there-a-javascript-jquery-dom-change-listener/11546242#11546242 – Louys Patrice Bessette Feb 19 '21 at 01:17
-
1The DOM API doesn't keep of record of all previous states. If you want a record, you have to track that yourself. If I say `someElement.innerHTML = ''`, I lose all data that might have been held in the DOM. – romellem Feb 19 '21 at 03:08