Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8321839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:09:48+00:00 2026-06-08T23:09:48+00:00

In the following getElementsByTagName(p)[0] and getElementById(demo) access the same element. Both of the following

  • 0

In the following getElementsByTagName("p")[0] and getElementById("demo") access the same element.

Both of the following work, so I can’t figure out why the jquery data function is even needed. Is the second not portable to all browsers.

$(document.getElementsByTagName("p")[0]).data("funcZ", function() {console.log("ZZZZZ")})

$(document.getElementById("demo")).data("funcZ")()

document.getElementsByTagName("p")[0].funcX = function() {console.log("XXXXX")}

document.getElementById("demo").funcX()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:09:50+00:00Added an answer on June 8, 2026 at 11:09 pm

    According the the jQuery website:

    The jQuery.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore free from memory leaks. jQuery ensures that the data is removed when DOM elements are removed via jQuery methods, and when the user leaves the page.

    It’s possible that by attaching random fields to a DOM element, when the DOM element disappears, the fields remain in memory. It looks like jQuery handles that for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble using the Element.getElementsByTagName method. With the following HTML: <p id=test>
I am using the following jQuery function in which i need to pass an
I have the following script: <script> (function(d, s, id, p) { var js, ins
I have the following code to get user data form facebook <div id=fb-root></div> <script>
I wrote the following class in javascript function main() { this.area ; this.$= function(target)
I have the following code, which logs in and out of Facebook fine, but
My following code will only alert once from Firebug, using jQuery's append. I was
I'm trying to get an object element from my webpage using getElementById (ultimately so
I have the following function that is supposed to get all elements in a
following code is write are not: selenium.GetEval(document.getElementsByTagName('a')[1].innerText); actually other scripts are working fine like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.