i have a <div> that contains several elements; i’ve added a link with which the user can open and close the div container and it runs fine.
I would like to close that container also when the user clicks another item, so i would like to trigger the open/close i’ve defined simulating the click in the open/close link but it does not run.
html code:
<div id=container_expand_collapse>Open-close</div>
<div id=project_div_container>
<div class=element>Element1</div>
....
</div>
JQuery code:
$('#container_expand_collapse').toggle(function() {
$('#project_div_container').animate({width: 10});
}, function() {
$('#project_div_container').animate({width: 120});
}
);
$(".element").click(function() {
$("#container_expand_collapse").trigger("toggle");
}
How can i force the toggle event?
Thanks!
better way