0

I am having a problem with my anchor tag from a separate page to the designated page, loading then bumping to the bottom of the page. Is there a fix for this? See link for complete code.

jQuery

 <script>
 jQuery(document).ready(function() {

  var allPanels = jQuery('.accordion > dd').hide();

  jQuery('.accordion > dt > a').click(function( e ) {
  e.preventDefault(); // don't use return false;
  allPanels.slideUp('normal');
  jQuery(this).parent().next().slideDown('normal');
  });

  jQuery(location.hash).show();

});
</script>

http://jsbin.com/cugagoruni/edit?html,css,js,output

http://demo.xhalocigsx.com/points/#reviewpoints

2 Answers2

1

Assuming the target page is yours, try changing this

<dt>
    <a name="#reviewpoints">Writing Product Reviews</a>...
</dt>

to this

<dt id="reviewpoints">
    <a href="#">Writing Product Reviews</a>...
</dt>

Named anchors are known to cause position problems, and in HTML5 there is no name attribute for anchors anyway. Also, the href attribute is required.

More info

In addition, you seem to have jQuery issues on the page:

Uncaught TypeError: $(...).ready is not a function

This usually means that either jQuery isn't available or you have an alias conflict with another library.

Update: You appear to be loading at least 3 versions of jQuery in that page. Are they being handled properly?

Community
  • 1
  • 1
isherwood
  • 58,414
  • 16
  • 114
  • 157
  • Okay I see what you mean, there is an issue with that. The
    doesnt open when I land on the page anymore with that line of code changed.
    – Jason Elliott Dec 04 '15 at 15:26
0

Just try using slideToggle:

$(function() {
    var allPanels = $('.accordion>dd');
    allPanels.hide();
    $('.accordion>dt>a').on('click',function(e) {
        e.preventDefault();
        el=$(this).parent().next();
        allPanels.not(el).slideUp();
        el.slideToggle();
    });
    $(location.hash).show();
});
Vixed
  • 3,429
  • 5
  • 37
  • 68
  • The anchored accordion tab is supposed to open up as well with the script im using. – Jason Elliott Dec 04 '15 at 15:47
  • It will, but you must fix your elements ID. I saw two id reviewpoints on your page. fix it and than you can use $(location.hash).show(); or $(location.hash).click(); in the code I posted, dipends of what you want to use, if the DIV or the A element – Vixed Dec 04 '15 at 15:57
  • You posted my code in a meta tag??? Ok, please, place it in a script tag at the bottom of your page, just before the

    tag. :/

    – Vixed Dec 04 '15 at 16:09
  • I added your script. and removed the ID's. I added an A name=reviewpoints – Jason Elliott Dec 04 '15 at 16:11
  • its in a script tag on the actual static block(page) – Jason Elliott Dec 04 '15 at 16:12
  • Now it just needs a small adjustment.... like an offset to the top about 200 pixels – Jason Elliott Dec 04 '15 at 16:13
  • no, it's not I'm looking at your code through the console... and you have` – Vixed Dec 04 '15 at 16:15
  • Jason please, trust me, you must delete the code I've done, put it between a `` and place it on your page. – Vixed Dec 04 '15 at 16:25