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?
 
leakim971PluritechnicianCommented:
you've an error somewhere else and javascript is broken

test page : http://jsfiddle.net/YW5eW/
0
 
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.