Multiple Toggle Links
Multiple Toggle Links
Hello all,
I'm new to jQuery. I find it easier and less typing then Ajax. My problem is that I would like to pass the div ID to my function so that I can use the function (toggle) in multiple places. I'm sure this is possible but not sure how to accomplish it. Can someone help? Thanks!
-
<script>
function toggle(id) {
$("div").click(function () {
$(id).slideToggle("slow");
});
});
</script>
</head>
<body>
<a onClick="toggle(id1);" href="#">Link</a>
<div id="id1">
This is the paragraph one!
</div>
<a onClick="toggle(id2);" href="#">Link</a>
<div id="id2">
This is the paragraph two!
</div>