javascript - How can I reference the ID of a separate html file using JQuery? -
<div id="container"> <nav> <ul class="clearfix" id="cfix"> <li class="icon" id="icon"> <a href="javascript:void(0);" onclick="mymenu()">☰ menu</a> </li> <div id="drop"> <li><a href="index.html#about">about me</a></li> <li><a href="index.html#resume">resume</a></li> <li><a href="index.html#music">music</a></li> <li><a href="index.html#contact">contact</a></li> <li><a href="blog.html">blog</a></li> </div> </ul> </nav> </div> <script> $(function() { $('#drop li').click(function() { $(this).addclass('selected').siblings().removeclass('selected'); }); }); </script>
i'm trying activate class [selected] id's referenced on separate html file [index.html] bio.html. code above works while on index.html, not bio.html.
i tried adding [href^='index.html#']
jquery selector no avail.
how can reference id of separate html?
i repeat, i'm sorry not understanding question despite made clear @ first.
to achieve you're asking for, add index.html file:
<script> $(document).ready(function(){ $("#drop").children().children("[href='index.html"+document.location.hash+"']").addclass('selected'); }); </script>
i hope you're looking for.
Comments
Post a Comment