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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:18:01+00:00 2026-05-14T07:18:01+00:00

The relevant snippet of HTML: <span class=a> <div class=fieldname>Question 1</div> <input type=text value= name=q1

  • 0

The relevant snippet of HTML:

<span class="a">
<div class="fieldname">Question 1</div>
<input type="text" value="" name="q1" />
</span>

The relevant jQuery:

$.each($('.a'), function(){
$thisField = $('.fieldname', $(this));
});

What exactly is being set to $thisField? If my understanding of multiple selectors in jQuery is correct, it should be grabbing the outer <span> element AND the inner <div> element. But for some reason, if I use $thisField.prepend("hi"); it ends up putting hi right before the text Question 1, but not before <div>. I thought multiple selectors would grab both elements, and that prepend() adds hi to the beginning of BOTH elements, not just the <div>

  • 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-05-14T07:18:01+00:00Added an answer on May 14, 2026 at 7:18 am

    The calling convention you are using is not a “multiple-selector” it is in fact searching within the context ($(this)) for a selector ('.fieldname'). See docs.

    You could do this to get the <div> and the <span>:

    $(this).find('.fieldname').andSelf().prepend('hi');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Relevant snippet from test.html: <div id="seat_31F_vacant" class="seatVacant" onclick="UpdateHost(this);Common.DoPostBack('lbtPostBack','31F');" onmouseover="Seat_onMouseOver(this)" onmouseout="Seat_onMouseOut(this)">F</div> Now consider this ruby
Here's the relevant code: <div data-bind=foreach: chats, visible: chats().length > 0> <input data-bind='value: $parent.newCommentText'
Relevant Code Snippet: public class MyPreference extends Preference { public MyPreference(Context context, AttributeSet attrs)
Here is a short snippet of HTML (it contains all relevant HTML and javascript
I have an input ( type='submit' ) in a div with a fixed width
Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {
Here is the code relevant to my question: http://jsfiddle.net/mkerny45/V23NK/ As you can see there
I'm loading a html snippet, insert it after a certain element and want to
This is a HTML snippet from my application: Correct answers: 0 / 6<br /><br
I want an array of objects to monitor (loading of) each span element (using

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.