I need to “reset” some page information based on the selected tab in a bootstrap jQuery tab section.
The docs show this event, which is exactly what I need: http://twitter.github.com/bootstrap/javascript.html#tabs
$('a[data-toggle="tab"]').on('shown', function (e) {
e.target // activated tab
e.relatedTarget // previous tab
})
I need to get the ‘href’ attribute of the e.Target and e.relatedTarget, which uniquely identify those 2 tabs and the 2 tab-content panes they are linked to.
Here’s my problem: the e object is some object that I’m not expecting or used to. I can’t use any of the jQuery methods like e.target.attr('href') — all the normal jquery methods I’m used to are gone. I tried accessing it like a raw object attribute — e.href , and got https://127.0.0.1/test?action=view#tab-a" not #tab-a
I can code a workaround with this – but I’m clearly doing something wrong. There should be an easy way to directly get #tab-a from e.target — but I can’t figure it out.
Try
$(e.target).attr('href')instead.