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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:37:31+00:00 2026-06-06T19:37:31+00:00

Using Jquery 1.6.4. I’m attempting to use css to give my app a clue

  • 0

Using Jquery 1.6.4.

I’m attempting to use css to give my app a clue as to the context of a user action by applying classes prefixed with context- at each layer of my UI.

So for a user clicking on something in the ‘search’ div I could assign the class ‘context-userContext-search’ and then everthing within that div would return that context when I call $(this).attr(‘class’) and so on and so forth down to the most descriptive context flags being applied to the element itself.

I’m doing this specifically to avoid having the define the entire heirarchy for each target element that needs it. But.. it doesn’t work.

My html:

<div class="context-userContext-search">
    <table>
        <thead class="context-layoutContext-tableHeader">
            <tr class="context-userContext-search">
                <th id="search_A2655_header" class="clickable sortable ui-state-highlight dialog_right_menu context-objectAttribute-A2655 context-objectClassName-host" value="A2655">
                    Hostname
                </th>
            </tr>
        </thead>
    </table>
</div>

When I call $('#search_A2655_header').attr('class') it returns this:

clickable sortable ui-state-highlight dialog_right_menu context-objectAttribute-A2655 context-objectClassName-host

When I expected it to return this:

context-userContext-search context-layoutContext-tableHeader clickable sortable ui-state-highlight dialog_right_menu context-objectAttribute-A2655 context-objectClassName-host

These classes of course do not exist within any stylesheets but I do not recall them having to for inheritance to work.

I could walk up the tree with .parents('[class^="context-"]'), but that is not nearly as cool and probably expensive.

Alternate methodologies to accomplish my goal are welcome.

  • 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-06T19:37:33+00:00Added an answer on June 6, 2026 at 7:37 pm

    What about this?

    var classes = 
      $('#search_A2655_header')
        .parentsUntil('.context-userContext-search')
        .andSelf()
        .attr('class')
    

    EDIT:

    I’ve been trying this on my own and doesn’t seem to work. Try with this instead:

    var getAllClasses = function (from, until) {
      var cs = []
      $(from)
        .parentsUntil(until)
        .andSelf()
        .each(function(){
          if (this.className)
            cs.push(this.className)
        })
      return cs
    }
    

    Demo: http://jsfiddle.net/elclanrs/3tR93/

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

Sidebar

Related Questions

Using Jquery Ajax i have an entry script index.php This script lets the user
Using jquery's .css() i am changing the left attributes value to move a div
(using jquery) I have the following function $(function() { $('tr.parent') .css(cursor,pointer) .attr(title,Click to expand/collapse)
Using jQuery validation plugin - http://docs.jquery.com/Plugins/Validation Wanting to use the remote method on a
Using jQuery Mobile, I want an alert to display when the user opens a
Using jquery (javascript) need to display facebook user name in html page using facebook
Using jQuery and using the ajax function, what causes it to use the error
Using jQuery timepickr: http://archive.plugins.jquery.com/project/jquery-timepickr Having included these files: jquery-1.7.1.min.js jquery-ui-1.8.21.custom.min.js ui.timepickr.js And getting this
Using Jquery TableSorter, I am creating a custom parser to sort elapsed time <td>
using jquery's .post i send do my php code an object that with var_dump

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.