javascript - How to attach click event to a Bootstrap tabs? -
have problem bootstrap tabs. want create tab-based menu submenu. on tabs there mouseenter event attached, when enter tab mouse pointer there appear links in submenu. of tabs not need submenu, need attach them click event, recognizes tab clicked , redirects me page. attached click event code:
$('#maintabpanel a').click(function (e) { e.preventdefault(); var $destination = $(this); if ($destination.hash === "#about") { window.location.replace("http://stackoverflow.com"); } });
but it's not working. can me?
edit
i've made example in jsfiddle: https://jsfiddle.net/romanus91pl/a12m71pf/5/
when click "bing link" anchors, redirect me bing.com site. want apply such event tab (when click it, should redirect me bing site).
if understand problem correctly, this
$(function () { $('#maintabpanel a').mouseover(function (e) { e.preventdefault(); $(this).tab('show'); }); $('#maintabpanel a').click(function(e) { e.preventdefault(); if (this.hash === "#about") { window.location.replace("https://bing.com"); } }); });
Comments
Post a Comment