English 中文(简体)
jQuery ui tabs anchoring, how to prevent it?
原标题:

I ve built a tab navigation, but everytime if i try to access the a certain div using the url with the hash #, it would then anchor to the section, is there anyway to prevent it from auto-anchoring? This is happening in FF and IE but not Safari.

My code looks like this.
JS:

$("#header").tabs({ fx: { opacity:  toggle  } });

HTML:

<div id="header">
<ul id="navigation">
    <li><a href="#debt" class="debt">Debt</a></li>
    <li><a href="#car" class="car">Car</a></li>
    <li><a href="#home" class="home">Home</a></li>
    <li><a href="#travel" class="travel">Travel</a></li>
</ul>
<div id="debt">xxx</div>
<div id="car">xxx</div>
    <div id="home">xxx</div>
<div id="travel">xxx</div>
</div>
最佳回答

Modern browsers parse a # followed by some string as an Anchor as you ve noticed.

There s really two solutions:

  1. Don t use hashes in your url

or

  1. Change the name of your tabs. (car_tab, debt_tab, etc..)

If you change the name of your tabs you can keep your hash url and add some JS to show the correct tab.

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签