How to update dom element selected by jquery?
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-07-05 10:43:06
0
3
783

For example, there is
<p class="ape">Element 1</p>
I use jquery to cache it into a variable:

var $ape = $('.ape');

Then I added a new one
<p class="ape">Element 2</p>
What method should $ape use to refresh itself at this time? How to enable it to select two apes at the same time?
I don’t want to have to $('.ape') every time I call it, I just want to call the cached variable $ape

女神的闺蜜爱上我
女神的闺蜜爱上我

reply all(3)
学习ing

The only way is to assign the value to $ape again every time an element is added

淡淡烟草味

It is recommended to use $('.ape') directly. Don't write code exactly according to your own wishes, try to adapt your code to the grammatical features. The code written this way is more valuable.

Ty80

Either reassign the value, or when inserting a node, trigger an event and reassign the value. Anyway, it’s just reassignment

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