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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:52:22+00:00 2026-06-04T05:52:22+00:00

I expect this code will change the text only on last div (Div5), but

  • 0

I expect this code will change the text only on last div (Div5), but it doesn’t:

<script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $(".blue", "#Div5").text("Hello");
    });
</script>

<form id="form1" runat="server">
<div>

    <div id="Div1" class="blue">AAAA</div>
    <div id="Div2" class="yellow">BBBB</div>
    <div id="Div3" class="blue">CCCC</div>
    <div id="Div4" class="yellow">DDDD</div>
    <div id="Div5" class="blue">EEEE</div>

</div>
</form>

Does anybody happen to know what’s wrong?

  • 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-04T05:52:24+00:00Added an answer on June 4, 2026 at 5:52 am

    The context is used for specifying a container element. In your example, you are referencing the same element in the context as your selector.

    You can simplify to this:

    $("#Div5").text("Hello");
    

    Or, if you still want to explicitly specify the class:

    $("#Div5.blue").text("Hello");
    

    Both will have the same result.

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

Sidebar

Related Questions

Consider this code below: <a href="javascript:void(-1)" id="a1">a1</a> <a href="javascript:void(-1)" id="a2">a2</a> <script type="text/javascript"> var buttons
This code gives me an empty result. I expect it to print out the
what behaviour can I expect when I run this code: do while(testA) { //
My expect code does this: It does a ssh connect to another machine, sends
Boy, this one is really weird. I expect the following code to print 1990,
I expect this might get some downvotes / closevotes but I'm going to ask
I'd expect this to be fairly routine, but cannot find a simple approach for
I expect the answer to this is already here someplace, but I was not
This might look like a basic question to some of you but I expect
The code works in ANSI perfectly but when I change the encoding to utf8

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.