Need to run the toggleSlide() jquery function when the user selects a value in the dropdown menu.
In Firebug i get the error "selectMenu is not a function" but i am not sure how to correct this as I am very new to javascript.
This is my Javascript:
<script type="text/javascript">
$("#selectMenu").bind("change", function () {
slideToggle();
});
</script>
Thanks!
EDIT:
Here is slideToggle():
<script type="text/javascript">
$("#slideToggle").click(function () {
$('.slideTogglebox').slideToggle();
});
</script>
Yes jquery is loaded correctly because I have other jquery elements working. Also, I do have the select menu's id set to "selectMenu"
Ian, unfortunately that does not work.
Meder, could you explain a little more please?
That doesn't make sense. It would make sense if you had a function named selectMenu
. Anyways, make sure you do it on DOM ready $(function(){ /* paste your code here */ });
and make sure you arent making typos.
You must put your jquery code inside the document ready wrapper:
$(document).ready ( function () {
$("#selectMenu").bind("change", function () {
slideToggle();
});
});
Are you certain you have a element with the id selectMenu
? This should work:
<select id="selectMenu">
<option>...</option>
</select>
<script type="text/javascript">
$(function() {
$("#selectMenu").bind("change", function () {
slideToggle();
});
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.