Basically, I'm trying to find a javscript function that finds the string "index.php?view=" in those links and replaces it with a "#" (hash symbol) when the page loads/document is ready.
I did the Google searches and every method I've tried seems to fail at doing anything- The scripts that I've tried have mostly been modified from web tutorials and, like I said, they haven't worked in the slightest. But if it would be helpful, I can post some of what I've tried if anyone would like.
Extra Note: I'm using jQuery localscroll plugin, which is why I need these links changed to hashes.
Thanks in advance,
2 Years Ago
var href = "index.php?view=cover";
href = href.replace(/^index\.php\?view=/,"#");
Thanks for the response, scrappedcola. I've got it working now with this code (placed within jquery's ready event):
var link = $(this).attr("href").toString();
var eindex = link.indexOf("=", 0);
link = "#"+link.substr(eindex+1);
Although this seems very bulky and un-jQuery-ish (maybe it's just aesthetics, but I feel my code looks really ugly compared to the nice-looking localscroll settings).
This is probably obvious, but I'm very new to jQuery (although I'm loving it). I know there's a lot of emphasis on "chaining", and despite the fact that my function is really just 5 lines, it seems it could do with some housekeeping.
Fret not, I will definitely mark this thread as solved. But before I do, I was just wondering if you (or anyone else) had any suggestions as to how I might simplify (or pretty-fy) what I've gotten. I'm not opposed to using regex, but I'm not very well-versed in it quite yet.