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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:21:34+00:00 2026-06-09T12:21:34+00:00

I am experiencing different results from the two following bits of code. I thought,

  • 0

I am experiencing different results from the two following bits of code. I thought, though, that they should perform identically. Could anyone enlighten me on the differences and when I should use one over the other?

function ContentHeader(selector){
    "use strict";
    var contentHeader = $(selector);

    var headerTitle = $('<span/>', {
        'class': 'headerTitle'
    }).appendTo(contentHeader);

    //OPTION A: This is my preferred method, but, after calling appendTo, no DOM element is added to the DOM tree.
    var headerTitleInput = $('<input/>', {
        'class': 'headerInput',
        type: 'text'
    }).appendTo(headerTitle);

    //OPTION B: By contrast, this method is less robust / just a string, but the DOM element is added correctly to the DOM tree.
    headerTitle.append('<input type="text" class="headerInput" />');
}

I would prefer to use jQuery’s DOM object constructor since it neatly encapsulates properties, but apparently I do not fully understand it.

EDIT: I am working on generating a jsFiddle for this question. Please check back.

  • 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-09T12:21:36+00:00Added an answer on June 9, 2026 at 12:21 pm

    I believe I tracked down the answer. Unfortunately, it’s nothing sexy or educational.

    When I create my ContentHeader object I return some public methods. One of which is called ‘SetTitle.’ It looks like so:

    setTitle: function(title){
      headerTitle.text(title);
    }
    

    This method is interacted with during an asynchronous code-execution block which reaches out to a server. It seems that the overhead of creating a jQuery object was generating different, awkward results based on timing. The issue was not reproduceable inside of a jsFiddle.

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

Sidebar

Related Questions

I'm experiencing some different behavior after switching from ASP.NET MVC 1.0 to ASP.NET MVC
We are experiencing different behaviour when running our .NET 3.5 process on 2 environments.
I am using JDK 1.6.0.18 for my Swing application. I am experiencing very different
I am experiencing a problem with IE caching the results of an action method.
I'm currently experiencing an issue with the custom mbean SNMP publishing function that WebLogic
I'm trying to join two relatively simple tables together, but my query is experiencing
I'm experiencing different behavior when running some integration tests via IntelliJ IDEA 10 and
Another developer and I are experiencing different behavior in native C++ executables built with
I am experiencing a memory leak with a code similar to the one below
We recently split our current work into two different VS solutions, one which contains

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.