Reputation: 9167
After opening an accordion item and then clicking on a new accordion item, I want it to first close the open one and then open the new one.
Here's my current code:
jQuery('.acclink').click(function () {
jQuery("#accordion").accordion("activate", -1); // this closes anything open
jQuery(jQuery(this).attr('href')).click(); // this is supposed to open the new one but doesn't. It WILL work when the above function is commented out.
return false;
});
Here's my page: http://www.savedeth.com/objectivescenes/ What am I missing?
Upvotes: 0
Views: 1951
Reputation: 379
I think you can use jqueryui's, accordion which does this by default.
Upvotes: 0
Reputation: 739
No need to type jQuery, $('#accordion').<method>
is enough.
Are you sure that jQuery(jQuery(this).attr('href'))
is selecting what you want?
Print it using console.log(Query(jQuery(this).attr('href')))
I think accordion already does everything you need by itself.
Probably $('#accordion').accordion()
is the simplest solution.
Upvotes: 0