I have a link in my menu. It has an attributte like title=.roc.
When I click on this link, I want to save this attribute and click on element with the same attribute on the destination page.
Page example.com. I click in the next link.
<li class="menu-item"><a title=".roc" href="https://example.com/port/#flash">Roc</a></li>
So now, in example.com/port/, it should click the element with title=".roc":
<a id="flash" href="#" title=".roc">ROC2</a>
I have this code, but I dont know how pass the attribute instead the hash:
jQuery(function ($) {
var activeTab = document.querySelector(location.hash);
history.replaceState(null, null, ' ');
window.addEventListener('load', function () {
if (activeTab) {
setTimeout(function(){ activeTab.click(); }, 100);
}
})
});
activeTab = location.hash==='#flash' ? $('[title]=".roc"') : $(location.hash)? Also why are you binding the load event in your DOM ready hook? If you want ot pass parameters other than just hash, you should use query parameters. URLSearchParams can build it for you