jQuery alert box not working
I have a tiny bit of code thats meant to show a javascript alert when a select list is changed value, but it doesnt seem to be working, could anyone give me a hand and let me know where im going wrong.
<script type="text/javascript">
$(document).ready(function(){
$("#sources").change(function(e) {
alert('This is what an alert message looks like.');
});
});
HTML for the select is as follows:
<select name="sources" id="sources" multiple="multiple">
<option value="">please select</option>
<option value="5">Seek</option>
<option value="6">friends</option>
&开发者_运维百科lt;/select>
Per your last comment, if jQuery is being used to generate the dropdown list on the fly, you need to use the .live()
function to bind your dropdown:
$('#sources').live('change', function(e) { //do stuff });
精彩评论