Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  41] [ 1]  / answers: 1 / hits: 18590  / 12 Years ago, thu, march 29, 2012, 12:00:00

I have this code which can display drop down in div tag of html. In this I have set one function hello() to that drop down through jquery but the problem is that its not calling that function.



<body>
<div id=content></div>
<script src=http://code.jquery.com/jquery-latest.js></script>
<script type=text/javascript>

$(#content).append('<select id=sel onchange=fly()><option value=1>Choose Me</option></select>');
$(#sel).attr(onchange, hello());
alert($(#sel).attr(onchange));

function hello() {
alert(Hello);
}

function fly() {
alert(Go to fly);
}
</script>
</body>

More From » jquery

 Answers
73

You need this.



$(#sel).change(hello);

[#86531] Wednesday, March 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
beatriceisabelad

Total Points: 710
Total Questions: 107
Total Answers: 99

Location: Cayman Islands
Member since Sat, Sep 17, 2022
2 Years ago
;