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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:08:58+00:00 2026-05-23T18:08:58+00:00

Something is wrong with my code. Chrome code spectrator say that there is probmel

  • 0

Something is wrong with my code. Chrome code spectrator say that there is probmel in line number 21, problem like this: Uncaught TypeError: Object #<HTMLElement> has no method 'parent'. This is jQuery code:

  $('.plus').click(function(){
    if ($(this).text() == "+"){    /* 1 IF       */
        $(this).text("-");

        if (! ($(this).parent().next().is('ul'))){            /* 2 IF */
        var element_id = $(this).parent().attr('id') 
        var id = '#' + element_id
        var url = "/accounts/profile/thingh_update/" + element_id + "/";

        $.getJSON(url, function(data){
        var items = []

        $.each(data, function(index, value) {    if(value.pk)        
        items.push('<li id="' + value.pk + '">' + value.fields.title + '&nbsp;&nbsp;<span class="plus">+</span></li>');});

        $('<ul/>', {
        html: items.join('')
        }).insertAfter(id); })
        } else {(this).parent().next().children().show()}    /* 2 ELSE */
      } else {$(this).text('+').parent().next().hide()}    /* 1 ELSE */
  })    
}) 

My html looks like this:

<ul>
    <li id="3"><a href="/my/proper/url/">this is for eat</a>&nbsp;&nbsp;
    <span class="plus">+</span></li> <!-- after clickin this I get proper json data, and "+" is cahnged to "-", and the next "<ul>" element appear -->
    <ul>
    <li id="4">fishes&nbsp;&nbsp;
    <span class="plus">+</span></li>
    </ul>
</ul>

And when I click on “-” in first “li” element and then again on “+” i get:

Uncaught TypeError: Object #<HTMLElement> has no method 'parent'

Maybe i missed something obvious, but I am not advanced in jQuery yet. I ask for some tolerance for beginner and any sugegestions of where could I do mistake.
Thanks.

  • 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-23T18:08:58+00:00Added an answer on May 23, 2026 at 6:08 pm

    On this line:

    } else {(this).parent().next().children().show()}
    

    You are missing the $ before (this), which means you are trying to call parent() on a DOM element, rather than a jQuery object.

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

Sidebar

Related Questions

There's something wrong with my code or I'm just not understanding this fully. I
Am I doing something wrong if I need code like this in a Controller?
There's something wrong with this code, or the way I've laid out my menu
Something must be wrong with this code right here: + (UIImage*)captureView:(UIView *)theView { UIGraphicsBeginImageContext(theView.frame.size);
Hi I got something wrong in my code and I don't know why My
Am I doing something wrong is this a known issue with the ASP.NET MVC
I have this code that dynamically slides up a Div over an image when
Is something wrong in :g-2-g/3/ or is the recursion in the global just missing?
Am I doing something wrong or is it not possible to specify a generic
I must be doing something wrong. I can't seem to execute my CustomValidator's ServerValidate

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.