I am trying to do the same thing as in this question Change the #hash tag for a link to a page load But I think because I get a string from the data-caption attribute of jquery objects, something is working incorrectly. I have a DOM element like this
<a class="thumbnail" rel="gallery" data-caption="#drink from somewhere #fun" data-pid="36" href="http://domain.com/something"><img src="http://domain.com/somephoto.png" alt="acee7bd0d8339b9ddcf4a259ec7ddeec"></a>
Basically this is a thumbnail loaded into a modal, then I try to grab the attribute header and create links from any hash tags
var caption = anchor.attr('data-caption') ? anchor.attr('data-caption') : null; console.log(caption);
where variable binding is a jquery object representing a link
I see that there is an inscription if I check the journal that it prints "#drink from somewhere #fun"
So now, throwing this into the regex, replace fn
caption.replace(/
Then add a title to the active link DOM.
But nothing happens with the title bar. I just get the same thing as me.
** CHANGE ANSWER silly mistake forgot to assign return value to variable
var captionLinks = caption.replace(/
Brian
source share