public/javascript/zebra_pagination.src.js displaying fragment at top of body
kb-freelance opened this issue · comments
Kallum Bell commented
When putting the script directly into the page in the footer - it is displaying the #fragment as plain text at the beginning of the body tag...
<body>#tabact6214
...content...</body>
The JS
$(document).ready(function() {
// get the hash in the URL (if any)
var matches = document.location.href.match(/\#(.*)$/);
// if a hash exists in the URL
if (matches)
// iterate through the pagination links
$('.Zebra_Pagination a').each(function() {
// reference to the element
var $element = $(this);
// attach the hash to every link
// (remember that the hash is not available server-side and that's why we're doing it client-side)
$element.attr('href', $element.attr('href') + '#' + matches[1]);
});
});
Stefan Gabos commented
shouldn't all this code come before the closing tag?