Home  >  Article  >  Web Front-end  >  Stay away from JS disaster and CSS disaster: js private functions and css selectors as containers_jquery

Stay away from JS disaster and CSS disaster: js private functions and css selectors as containers_jquery

WBOY
WBOYOriginal
2016-05-16 17:58:331187browse

Although js can construct objects and hide private methods like an object-oriented one, when the needs often change faster than you can write a program, there is no time to even design js objects, so I prefer to use js private functions and js method; jquery private function and jquery externally exposed method can also be implemented, and the html structure generated by the page is completely generated in js, including which ids and classes, so as to ensure the convenience of unification and reuse to the greatest extent, but There is also a disadvantage, that is, when reusing, if the style needs to change (the structure is fixed and cannot be changed), the original structure needs to be wrapped with div, and the relevant styles also need to be wrapped with the corresponding id. If it is a new Events, etc. can only be bound by binding, and there is currently no good method.
For example, I want to include several pictures in a div
There is also a disadvantage in doing so. Only the css must be copied once. Making modifications but reusing the structure, style and js

Copy the code The code is as follows: