Javascript Code
Please Note – this doesnt work with old version of js File
$('document').ready(function(){ $('#cboCity').live("change", function(){ alert('Hi there'); }); $('#btnChange').on("click", function(){ changeCities(); }); }); function changeCities() { strSelect = "<select id='cboCity' name='cboCity'><option>Chennai</option><option>Mumbai</option></select>"; $('#City').html(strSelect); }
HTML Code
<input id="btnChange" type="button" name="btnChange" value="Change Me" /></pre> <table> <tbody> <tr> <td> <div id="City"> <select id="cboCity" name="cboCity"><option>Chennai</option><option>Mumbai</option><option>Delhi</option><option>Kolkatta</option><option>Andrapradesh</option> </select> </div> </td> </tr> </tbody> </table>