javascript - Anchor Link to Multiple Locations using jQuery -
i'm working piece of code:
fiddle: http://jsfiddle.net/2hmzcgqm/12/
right can use #rugby
taken span
within accordion.
i'd able extend use #football
also. can help? :-)
javascript:
(function($) { var allpanels = $('.accordion > dd').hide(); var alllinks = $('a.heading'); $('.accordion > dt > a').click(function() { allpanels.slideup(); //remove alllinks.removeclass('active'); if ($(this).parent().next().is(":visible")) return false; $(this).parent().next().slidedown(); //add active class $(this).addclass('active'); return false; }); //$('.accordion > dt > a').first().trigger('click'); function setaccordion() { // id url // var url = window.location.pathname; // test url var url = 'localhost:58000/gallery#rugby'; var id = url.substring(url.lastindexof('#')); // give #football var spantag = $('.accordion').find(id); //#football span tag var parenttag = spantag.closest('dd'); //open accordion allpanels.slideup(); parenttag.slidedown(); parenttag.prev('dt').find('a.heading').addclass('active'); } // call function setaccordion(); })(jquery);
first of can't write full code you, that's not point of stackoverflow. can out search in right direction.
if want multiple elements define in url can see following example jquery reading several array parameters url
then catch params url , create array iterate on open or set correct accordion item.
var arrayparams = []; $.each(arrayparams, function(key, value) { // every item url , open correct accordion item });
Comments
Post a Comment