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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:04:35+00:00 2026-06-05T05:04:35+00:00

I’m starting to use JavaScript and jQuery a bit more than just to do

  • 0

I’m starting to use JavaScript and jQuery a bit more than just to do some shiny effects and I have a question about a fundamental thing in jQuery. I often have no idea what I’m really working with in jQuery.

For example, if a have the following markup:

<img class="image" src="picture.png" width="100" height="100" />

And in jQuery do

var img = $('.image');

img then is not the same as when I do

var img = $('<img class="image" src="picture.png" width="100" height="100" />');

But if I for example want to create a new image on image and run some jQuery functions on it, like .css(), I have to do:

var img = $('<img class="image" src="picture.png" width="100" height="100" />');
img.appendTo('.myElement');
$('.image').css("border","none");

Which is kind of a double step?

My Question: What are the different typs of things I’m handeling with here? What’s the difference between the fist two examples? I want to understand what actually the elements are I’m daling with when working with jQuery/JavaScript.

My Question [Update]: I may have been a bit unclear, I don’t want to know what the examples actually do, but what I select/create when I call these functions (a pointer to an DOM element, a string in JavaScript that represents HTML but still has to be added to the DOM to be displayed, etc.).

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

    When you pass a selector (e.g. $('.image')) to the jQuery function, it does just that: selects. The jQuery object will contain all elements that are already present in the DOM that match that selector.

    When you pass a HTML string to the jQuery function, it creates a jQuery object that contains the element(s) that the HTML represents. However, it doesn’t automatically add them to the DOM, so you can’t select them; you need to use one of the various methods to add them – .append(), .appendTo(), .before(), .after(), etc.

    Your CSS manipulation example, however, is flawed, because you can chain jQuery functions together. You can combine that into a single line of code:

    var img = $('<img class="image" src="picture.png" width="100" height="100" />')
              .css("border","none")
              .appendTo('.myElement');
    

    If that’s all you want to do with the element, then you don’t even need to save it to a variable. If, however, you’re going to want to use it again later, then it may be faster to do so; depends on exactly what you’re going to be doing with it.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,

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.