0

So, i was reading the jquery documentation and i couldn't identify the differences between the functions jQuery.data() and .data(). What are the main difference between those functions?

Here is the link to documentation: Doc jquery

2 Answers 2

1

The latter is just a more convenient syntax for the former: $.(domElement, 'key') and $('selector').data('key') do the same thing.

Sign up to request clarification or add additional context in comments.

Comments

1

From the link you provided - it would appear it is simply just an older way of calling the same functionality in a more 'vanilla javascript' way...but it would appear there is one actual difference listed.

Note: This is a low-level method; a more convenient .data() is also available.

Regarding HTML5 data-* attributes: This low-level method does NOT retrieve the data-* attributes unless the more convenient .data() method has already retrieved them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.