开发者

Change event for combobox not getting fired in jQuery

开发者 https://www.devze.com 2023-01-08 08:45 出处:网络
I am working in PHP. I have written code for displaying a combo box like this: <select name=\"country\" id=\"idCountry\" class=\"clsCountry\" >

I am working in PHP. I have written code for displaying a combo box like this:

<select name="country" id="idCountry" class="clsCountry" >
    <?php foreach($objCountries as $objCountry):?>
        <option value="<?php echo $objCountry->getId()?>" ><?php echo $objCountry->getName()?>   </option>
    <?php endforeach;?>
</sele开发者_运维知识库ct></td>

For change event:

$("#idCountry").change(function(){ .... });

but change event is not getting fired. How can I fix this problem?


First, is the code placed inside the ready function of the document?

$(document).ready(function()
{
     //code here
});

Or try this:

$("#idCountry").ready(function()
{
  $("#idCountry").change(function(){
    //code here
  });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消