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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:53:12+00:00 2026-06-17T19:53:12+00:00

I know how to accomplish this if I can identify this element using a

  • 0

I know how to accomplish this if I can identify this element using a selector:

$("selector.class")

But what if my selector is the keyword this? Obviously $(this".class") isn’t going to work, and I don’t want to use $(this).children(".class") because then I need to extract the HTML of the element using .html(), and while I know that there will only be one element of this class in the selected element (I’m writing the HTML), JQuery doesn’t, and it assumes that children() returns several elements when used with a class (at lease I think that’s what it does, because

$(this).children(".class").html()

returns undefined).

Is there an other way I could do this?

Please feel free to ask for clarification, I understand this may not seem clear to some.

EDIT: some of you asked for clarification, so here it is. Let me rephrase the question: normally, when I ask JQuery to get me some elements, and give it a class as a selector it assumes I will get more than one element back and therefore $(".selector").html() doesn’t work, because you can’t get the HTML of several elements (at least that’s my theory). Instead, I want it to recognise that in this case I am only getting 1 element back, and treat is as such. My restriction is that part of my selector is this. I hope that helped!

  • 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-17T19:53:14+00:00Added an answer on June 17, 2026 at 7:53 pm

    It isn’t entirely clear to me what question you’re asking so here are several different options:

    To search for any subordinate tags (in the DOM tree with this as its root) that match a desired selector:

    $(this).find(".myClass");
    

    Or, if you’re just trying to see if the this element has a particular class name, you can use:

    if ($(this).hasClass("myClass")) {
        // this element has the desired class
    }
    

    or, if the selector is more complicated than just a class, you can use .is() like this:

    if ($(this).is("selector")) {
        // this element matches desired selector
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can accomplish this in PHP but I really need to have
This can't be too hard, but I don't know what the term is I'm
I don't know how to accomplish this! how to get the function pointer in
I know I can accomplish it with custom components (I'm doing it right now
Know this might be rather basic, but I been trying to figure out how
I know you can not set a key value dynamically, but what about the
I know that this sort of question has been asked here before, but still
In my Rails template, I'd like to accomplish final HTML to this effect using
In AS3, I know how to accomplish this. One needs only to click ActionScript
Does anyone know how to accomplish a different layout based on the browser width,

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.