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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:34:17+00:00 2026-06-14T11:34:17+00:00

My jQuery question I beleive is pretty simple, which is driving me insane that

  • 0

My jQuery question I beleive is pretty simple, which is driving me insane that I can’t get it.

I have an object with a property “content”, I want to be able to take that object, manipulate the property “content” with jQuery and then overwrite the value with the new value jQuery creates.

Example:

o.content = "<div><span>hello</span></div>";
$('div', o.content).addClass('test');

At this point I want o.content to be equal to <div class='test'><span>hello</span></div>

I can not for the life of me figure out the syntax. Any help is really appreciated.

  • 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-14T11:34:19+00:00Added an answer on June 14, 2026 at 11:34 am

    from the docs of the jquery function, context must be

    A DOM Element, Document, or jQuery to use as context

    Your context (o.content) is a string. Also, the jQuery function is not able to select the entire context, it can only select elements in that context.

    Try this instead:

    // make o.content a jquery element, not a string
    o.content = $("<div><span>hello</span></div>");
    
    // select on something inside the context (inside the div), not the div itself
    $('span', o.content).addClass('test');
    

    http://jsfiddle.net/JfW4Q/

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

Sidebar

Related Questions

I am using the jQuery-File-Upload widget (although I believe this question can generalize to
Another jQuery question for you guys. Say I have a url of an image
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
Another jquery calculation question. I've this, which is sample code from the plugin site
i have a very conceptual question regarding jquery. i have this fiddle http://jsfiddle.net/zvCrN/ What
i have one question about jquery ajax().. I created a table grid and there
I have quick question about jQuery plugins, hope somebody out there has some advice.
Hi I have a simple ajax search that returns the results in a table.
I have another jQuery question. For a user control with lots of database activity,
My question I believe is pretty simple, yet I haven't found a good answer.

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.