javascript - jQuery doesn't locate specified anchors in bootstrap template -



javascript - jQuery doesn't locate specified anchors in bootstrap template -

i using dashboard bootstrap template , want utilize jquery swap contents on click of specified links. here's code:

<div class="container-fluid"> <div class="row"> <div class="col-sm-3 col-md-2 sidebar"> <ul class="nav nav-sidebar"> <li class="active"><a href="#">overview</a></li> <li><a href="#">membership requests</a> </ul> <ul class="nav nav-sidebar"> <li><a id="switch" href="http://www.google.com">list news</a></li> <li><a href="">list announcements</a></li> <li><a href="">list members</a></li> <li><a href="">list accounts</a></li> </ul> ...

jquery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("a#switch").click(function() { alert('ok'); $('#content').load(this.href); homecoming false; }); }); </script>

jquery not locate anchor 'switch' id. problem this? give thanks you

$("a#switch").on('click', function(e) { $('#content').load(this.href); homecoming false; });

might work. event may fires on other elements.

javascript jquery html twitter-bootstrap

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -