Goal: I have some existing content (a lot of text and multiple pages) that I'm updating to hide/segment in a dynamic jQuery slider (creator's demo page & code here). However, the content is full of internal links in various locations, that I don't want to have to update individually.
Solution possibilities I came up with: (a) create jQuery to automatically detect which slider div the anchor is inside of, and automatically open that, or (b) if the URL contains a hash tag, trigger the openAll function to open all the sliders, and then after that, scroll to the anchor location.
Issues: I'm new to this. I went with option B and think my code has the right idea, but it breaks the page. Ideas?
var hash = location.hash.replace('#', '');
$('body').find('ul'+hash+':first');
function hashload {
if(window.location.hash) {
$('.collapsible').openAll();
$('html, body').animate({
scrollTop: $('#'+hash).offset().top}, 'fast');}}
Relevant resources that might have the key to it all (aka what I was basing this on...): Link to an anchor within JQuery tabbed content (and the accompanying solution here: http://jsfiddle.net/TGMDd/65/)
don't execute script if url contains # ...and: Getting URL hash location, and using it in jQuery
JQuery scroll to anchor on click?
Many thanks for your time!