leoatcle
leoatcle

Reputation: 3

jQuery click/change even on select is not working

I'm trying to capture the change of the drop list, however the click and change event didn't work no matter in ff or chrome. Here's the source html code:

<select class="select" id="querycond_select_Baitgenesymbol" style="max-width: 400px">
    <option>APC</option>
    <option>CTNNB1</option>
    <option>DNMT1</option>
    <option>ELF3</option>
    <option>EPHB2</option>
    <option>MRE11</option>

and jQuery:

$('.select').click(function() {
    alert("!!!!!!!")
});

I also tried to replace the click with change, but it didn't work out for me too.

Upvotes: 0

Views: 3601

Answers (3)

optimusprime619
optimusprime619

Reputation: 764

works just fine ... http://jsfiddle.net/tXy6Q/ try adding it in document.ready()

  • if the select box is added dynamically based on logic would recommend using live() method..

  • use the change event rather than click

  • also check for any errors using firefox error console ..

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382776

Make sure to:

  • include jQuery on your page
  • Wrap your code in ready handler
  • use change instead of click

$(function(){
  $('#querycond_select_Baitgenesymbol').change(function() {
    alert("!!!!!!!");
  });
});

Upvotes: 2

James Johnson
James Johnson

Reputation: 46057

Try this:

$(function(){
    $("#querycond_select_Baitgenesymbol").change(function(e){
        alert("here");
    });
});

Upvotes: 0

Related Questions