I want some return about dom manipulation. I think we can save elements’ status in several ways. For exemple, you want to make an element “inserted”, what do i have to use? :
- Add css class as “inserted”
- Save an attribute with .data(“inserted”,true)
- Push my element in a global array containing all “inserted” elements
- …
But what is the best way? Maybe the solution is to use all possibilities. I don’t know.
That’s a general question. I don’t have a specific problem, but i am starting developing a huge javascript application and i want to choose my rules 🙂
Do you want selected elements to look in a specific way?
–> Use the css-class
Do you want to check whether a specific element is selected at a different place in code?
–> Use .data
Do you want to do something to all selected elements?
–> Use an array.
If you plan to do multiple of the things above, you can also combine the approaches.