search

Home  >  Q&A  >  body text

css - JavaScript/Jquery style reset problem, please give me some advice

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.

伊谢尔伦伊谢尔伦2743 days ago741

reply all(5)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-24 11:39:03

    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.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-24 11:39:03

    Describe the problem in detail, preferably with code.

    reply
    0
  • 黄舟

    黄舟2017-05-24 11:39:03

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

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-24 11:39:03

    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

    reply
    0
  • PHPz

    PHPz2017-05-24 11:39:03

    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|
    |-------| |-------| |----- --|

    reply
    0
  • Cancelreply