css - JavaScript/Jquery style reset problem, please give me some advice
伊谢尔伦
伊谢尔伦 2017-05-24 11:37:03
0
5
761

By default, a method A() is executed, which will modify the order and style of the elements, and then need to restore these elements to their original state. Could you please tell me how to do this? The most important thing is that method A is executed by default. If you want to reset it after some operations, you can implement either jquery or native methods.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(5)
给我你的怀抱

I have found the simplest method myself, but thank you for your enthusiastic answers. Here I will briefly share my ideas: jquery or original are the same, just delete the style attribute of the element directly, because all JS style operations are based on style Attributes.

给我你的怀抱

Describe the problem in detail, preferably with code.

黄舟
你可以试试用排他思想。先循环所有元素,把每个元素上的样式清空,然后当触发每个元素的绑定事件时,在给该元素加上要加的样式。
仅有的幸福

Before going through method a, store the value of a in localstorage. When it needs to be reset, just assign the value of a in the storage to the variable of a

PHPzhong

Now, the original data remains unchanged (if all you get at the front end is DOM, you can traverse it once and make a JSON data source) and make a temporary domain object for the middleware; HTML is presented through JS; JS modification only modifies the middleware. Just leave the original data unchanged; the so-called "reset" is actually re-initialization (if there are modifications, save the modifications and then initialize again);

This cannot be rolled back
|-------| |-------|
|Original data| ==> |-DOM modification|
|-------| | -------|

In this case, if you "reset", it actually just clears the DOM and remaps it from the original data;
|-------| |-------| |----- --|
|Original data| ==> |Object in domain| ==> |-DOM mapping|
|-------| |-------| |----- --|

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template