What is the difference in jQuery between prop and data? You can just prop ('blabla', value), why use data ()?
I will add: if you need to save any info to the element, then prop or data is better?
What is the difference in jQuery between prop and data? You can just prop ('blabla', value), why use data ()?
I will add: if you need to save any info to the element, then prop or data is better?
.data allows you to get the date attribute value and cache it in an internal object. Cannot set attribute .
.prop sets the value of a specific element property.
If you just need to store some information, it is better to use data .
elem.data('property-name') аналогично elem.prop('data-property-name') That's all the difference
prop does not take values from attributes, it takes values from properties. Just add a snippet to your answer, demonstrating that these calls are really similar - GrundySource: https://ru.stackoverflow.com/questions/595406/
All Articles