Reputation: 199
I need some help with my website. I want to integrate the jquery toggle function. But it doesn't work. I don't have a lot experience with jQuery.
Here is my code:
<a href="javascript:toggle('exp');">Klick</a>
<div id="exp" style="display:none;"> hallo </div>
<script src="jquery-ui-1.10.3/js/jquery-1.9.1.js"></script>
<script src="jquery-ui-1.10.3/js/jquery-ui-1.10.3.custom.js"></script>
<script>
function toggle(str)
{
$(str).slideToggle('slow');
}
</script>
Has anyone an idea why it doesn't work?
Upvotes: 1
Views: 49
Reputation: 36
You need to specify what to toggle.
$("#exp").slideToggle('slow');
See Jquery doc: http://api.jquery.com/toggle/
Upvotes: 0
Reputation: 115262
Missing #
before id selector in your code.
function toggle(str){
$('#' + str).slideToggle('slow');
//-^----
}
Upvotes: 2