Event fires first time only?

In the code below, the alert message fires the very first time I pick something from the drop down list.

But after that, the alert message does not fire when I choose something from the same drop down.




$(document).ready(function ()
{
    var loc = window.location.href.toUpperCase();

    if (loc.indexOf("COURSESEARCH") != -1)
    {   

        $("select").change(function ()
        {
    
            $("select option:selected").each(function ()
            {
                  alert($(this).text());
    
            });
    
        });
    

    }
});

Open in new window

LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
you've an error somewhere else and javascript is broken

test page : http://jsfiddle.net/YW5eW/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom KnowltonWeb developerAuthor Commented:
No argument that js.fiddle code works.

I need help tracking down where the javascript might be broken.


Let me put together a test page of my own and see if I can narrow this down.
0
Atique AnsariCommented:
Are you using any other Javascript framework?
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Tom KnowltonWeb developerAuthor Commented:
I don't think so...
0
leakim971PluritechnicianCommented:
Firebug report nothing ???
0
Tom KnowltonWeb developerAuthor Commented:
I tried looking for errors in the Firebug console, but none were reported
0
Atique AnsariCommented:
Try below code.


      jQuery(document).ready(function($)
      {
          var loc = window.location.href.toUpperCase();
            
            if (loc.indexOf("COURSESEARCH") != -1)
            {
                  $("select").change(function ()
                  {
                        $("select option:selected").each(function ()
                        {
                              alert( $(this).text() );
                        });
                  });
            }
      });
0
Tom KnowltonWeb developerAuthor Commented:
thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.