I’ve a page with many divs that shown products (title and description) but description is hidden and when click in title, description has slideToggle effect
DIVS HTML
<first><h4>Product1</h4></first>
<span><div><ocultar>Description</ocultar></div></span>
<second><h4>Product2</h4></second>
<span><div><ocultar2>Description</ocultar></div></span>
....
...
...
And third, fourth, etc...
And I want a function that optimize this functions in unique function..
$("ocultar").slideToggle("slow");
$("first").click(function () {
$("ocultar").slideToggle("slow");
});
$("ocultar2").slideToggle("slow");
$("second").click(function () {
$("ocultar2").slideToggle("slow");
});
...
...
...
I hope can help me!
What you could do is add a class attribute to your elements and that will make it easier to manipulate with jQuery.
This jQuery will now attach itself to each click event on the element with the
titleclass attribute and display the closest div with thedescriptionclass attribute.Demo