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 7218803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:31:54+00:00 2026-05-28T21:31:54+00:00

I am trying to use $(this).parentNode.attr(‘data-element’) which should return 0 – 5 in string

  • 0

I am trying to use

$(this).parentNode.attr('data-element')

which should return 0 – 5 in string but it just won’t work. I am using it in a function like this

$('.someClass').each(function(){
    $(this).html(SomeFunction('SomeString', $(this).parentNode.attr('data-element')));
});

All the elements with class ‘someClass’ have a parentNode

<li class="element" data-element: 1 (or any number from 0 to 5 (including))> </li>

and I have no idea where is the mistake. What am I doing wrong?

–David

  • 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-05-28T21:31:55+00:00Added an answer on May 28, 2026 at 9:31 pm

    You are mixing jQuery and plain javascript in the same line of code and that will not work. You can either use:

    $(this).parent().attr('data-element');   // jQuery
    

    or

    this.parentNode.getAttribute("data-element");   // plain javascript
    

    parentNode is not a property of a jQuery object, so you can’t mix the two the way you were doing it. The jQuery method for getting the parent is .parent().

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

Sidebar

Related Questions

Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I'm trying to use this layout with two 50% column width instead. But it
I'm trying to use: // this is a BreakHistory class from the ADO.NET Data
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
trying to use this jstl to formulate a json string, how can i make
I am trying to use this code: public string GetCPUId() { string cpuInfo =
I'm trying to use this class to import a large amount of data. Most
I use this code: I'm trying to remove the categoryPath node but keep its
I am trying to use this query upon my Android database, but it does
I am trying to use this package: http://pypi.python.org/pypi/guess-language/0.1 I've read the documentation/wiki, but can't

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.