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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:25:21+00:00 2026-05-25T06:25:21+00:00

Simple answer: The jQuery library my code base was using was out of date.

  • 0

Simple answer:

The jQuery library my code base was using was out of date.

If yours is up to date try the following:

  1. Step though the unminified version of jQuery to see if the issue is inside the library (which 9 times out of 10 it probably will not be)

  2. When all else fails, just write a pure javascript solution.


Sometimes when I am writing a “class” in javscript with jQuery, jQuery will just not function as it should. For example today I was doing the following on an input select:

$(this).val(newValue);

This was working in jFiddle just fine, but not working in my project (both had 0 script errors). I tried to isolate the code as much as possible, but to no avail I could not get it to work.

The “solution” for this was to just write straight up javascript to set the value and it worked just fine.

I am not a jQuery master, but this is not the first time I had to write a straight javascript solution when jQuery “failed.” Do any jQuery masters out there know why something like this might happen? Is there a method of debugging jQuery I am not aware of? Does anyone else run into these types of problems with jQuery? If so, do you have a solution?


Update(s):

Aug 25, 2011

I downloaded the most recent version of the jQuery library and stepped through it only to find that the bug was probably resolved between jQuery 1.4.4 and 1.6.2. I didn’t realize the person who handles most of the javascript wasn’t keeping the jQuery library up to date. After stepping through the jQuery 1.4.4 library it seems that jQuery was not able to find my selector for some reason and therefore was never setting the value. This problem has been resolved in 1.6.2….

Lesson of the week… keep your jQuery library up to date and verify your senior developer’s statements when things aren’t matching up.

–

I chose the answer I did because it was the only one which really helped me diagnose the source of the problem. While stepping through the unminified version of jQuery is such a simple solution, I actually should have done that before posting this question. I will post my findings as to why it didn’t work later.


Aug 24, 2011

I agree with the user Sohnee that having a duplicate ‘name’ isn’t bad practice and in some places you actually need it.

I feel rather stupid because the posted code has been wrong for almost a week now. I have updated the code. I moved the init function to the public scope.


Aug 22, 2011

While I am partially satisfied that the core of the problem is with duplicate names, I need to know why are duplicate names bad?

I know when dealing with inputs/css/etc you usually except IDs to be unique and classes to represent groups. I didn’t think there were any rules about names, but if someone can explain to me why having duplicate names is bad practice, I will consider that the answer to this problem.


Aug 16, 2011

As for the current answers, I don’t think it is a conflict. jQuery is working just fine. The binds are triggering causing the functions to be called in both implementations.

The problem line is

$(overrideSelector).each(
    function(){         
        $(this).val(newVal);
    }
);

For example, if I console out newVal in the .each() it will have a value of lets say ‘A’.
Then if I console log out $(this).val() it will be ‘B’. Then $(this).val(newVal); is run. After that if I do a console log of $(this).val() it will still be ‘B’.

In the comments someone mentioned that I might be using the word this wrong. Both of these returned 0 javascript errors on Chrome’s console. I will give the following code snippet was what was having problems. I will write the original and then what I replaced it with javascript.

I am aware the name is the same, but that is ok. The page I am working on is a huge form and the cloned select is just to make the user not have to scroll back to another part of the form.

HTML:

<div id='overrideHolder'>
</div>

<select name='mySelect'>
    <option value='A'>A</option>
    <option value='B'>B</option>
</select>

jQuery (this does not work):

var someClass = (function(){
    var overrideSelector = '[name="mySelect"]';
    ...

    return{
        init : function(){
            $(overrideSelector).clone().appendTo('#overrideHolder');
            $(overrideSelector).each(
                function(){
                    $(this).bind(
                                 'change', 
                                 {}, 
                                 function(){
                                        someClass.overrideTryAgain(this);
                                 }
                    );
                }
            );
        }

        overrideTryAgain : function(element){
            var newVal = $(element).val();

            $(overrideSelector).each(
                function(){         
                    $(this).val(newVal);
                }
            );

            ...
         },
         ...
    } 
})();

$(document).ready(function(){
    someClass.init();
}

Javascript (this works):

var someClass : (function(){
    var overrideSelector = '[name="mySelect"]';
    ...

    return{
        init : function(){
            $(overrideSelector).clone().appendTo('#overrideHolder');
            $(overrideSelector).each(
                function(){
                    $(this).bind(
                                 'change', 
                                 {}, 
                                 function(){
                                        someClass.overrideTryAgain(this);
                                 }
                    );
                }
            );
        }

        overrideTryAgain : function(element){
            // NOTE: Using javascript instead of jQuery because jQuery was not duplicating the selected value properly
            var newValue = $(element).get(0);
            newValue = newValue.selectedIndex;

            $(overrideSelector).each(
                function(){
                    var currentSelect = $(this).get(0);
                    currentSelect.options[newValue].selected = true;
                }
            );

            ...
        },
        ...
    }
})();

...

$(document).ready(function(){
    someClass.init();
}
  • 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-25T06:25:21+00:00Added an answer on May 25, 2026 at 6:25 am

    I tried to reproduce the problem from your code, and like others could not do so. So it seems like there’s something external that is interfering: a conflict, something with the markup, but generally something that’s not obvious.

    This sounds like a job for source-code stepping. Run this against the non-minified jQuery and trace the offending line with a debugger such as the built-in Chrome debugger or Firebug to see what’s happening inside jQuery. This should reveal what’s going wrong, be it a jQuery bug or something in your own code/markup that you didn’t see before.

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

Sidebar

Related Questions

A small question hopefully with a simple answer, I am using jQuery draggable and
This may be a simple answer, but I'm using jQuery's $.ajax to call a
I'm new to jQuery so this may be a real simple answer. I have
This is probably a really simple jQuery question, but I couldn't answer it after
I have a simple html form that I've added validation to using the JQuery
This may turn out to be a simple question with a very complex answer,
I think this should be simple. Say I've got the following jQuery: $someForm.live('submit', function(event)
I am using jquery-tmpl and receiving the following JSON data, which I am using
I am using jQuery UI (1.8.16) extensively in my application. I've developed a simple
Once you’ve taken the leap to start using the jQuery library (or another JS

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.