How do I call the url inside the anchor tag when opening the accordion?
Suppose I have the following code:
<div id="accordionLeftNav">
<div class="accordionBox" id="accordionStyle">
<h3><a href="url">Here</a></h3>
</div>
</div>
Now I have the following js
if ($("#accordionLeftNav").length > 0) {
$("#accordionLeftNav").accordion({
header: "h3",
heightStyle: "content",
collapsible: true,
navigation: true,
active: false,
icons: {
"header": "open",
"activeHeader": "close"
}
});
}
Now I want to call the url inside the anchor tag when opening the accordion. Please help me to solve this problem.
+3
source to share
1 answer
I fixed this. here is the code:
if ($("#accordionLeftNav").length > 0) {
$("#accordionLeftNav").accordion({
header: "h3",
heightStyle: "content",
collapsible: true,
navigation: true,
active: false,
icons: { "header": "open", "activeHeader": "close" },
activate: function( event, ui ) {
var headerUrl = ui.newHeader.find('a').attr("href");
window.location = headerUrl;
}
});
}
0
source to share