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

  • Home
  • SEARCH
  • 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 8974085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:36:00+00:00 2026-06-15T18:36:00+00:00

var classFind= $(‘.frame’).parent().parent().parent().parent().parent(); if (classfind.hasClass(.class)) { return true; } I have a class that

  • 0
var classFind= $('.frame').parent().parent().parent().parent().parent();
if (classfind.hasClass(".class")) {
            return true;
        }

I have a class that is located according to this path^… How could I loop through the dom to automate this process with better code readability? If it does not find the .hasclass before it hits a null then simply return false.

  • 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-15T18:36:01+00:00Added an answer on June 15, 2026 at 6:36 pm

    Can’t you just replace this with…

    return !!$('.frame').closest('.class').length;
    

    The closest methods travels up the DOM tree until it finds the element that matches the selector given as its param – and then stops immediately; it will return empty collection of elements (which is still an object, hence its length should be checked) if no such element is found. And !! is the same as Boolean() call – it’s not required, but will make your function return boolean values (true/false) instead of 0/1.

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

Sidebar

Related Questions

My class relationship: ClassMaster 1----* ClassSessions My Goal: Return all ClassMasters that have ClassSessions
I have this client-side: $(document).ready(function() { var $checkboxes = $('[type=checkbox]'); $checkboxes.click(function() { $checkbox =
Hi I have that html snippet <span class=container> <span class=inner> <span class=img_class> <img id=img1
I have this foreach -loop: foreach (var classId in m_ClassMappings[taAddressDefinition.Key]) { if(!m_TAAddressDefinitions.ContainsKey(classId)) { m_TAAddressDefinitions.Add(classId,
I have this query: (from a in SickDays join b in Class.Where(p => p.ID
I use EntityFramework with POCOs. Suppose I have POCOs defined like this (simplified): class
var fruit = [apple,pear,pear,pear,banana]; How do I remove all pear fruit from this array?
I have an applet, which I was writing in Java. Recently, I thought that
I have the following code. <div class=container> <input type=hidden name=id value=123 class=id /> <div
I have the following javascript code (at bottom) that I inject per api call

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.