English 中文(简体)
低落导航中的可分母联系
原标题:Disable parent link in dropdown navigation

我有一条航道,例如:......

<ul>
    <li><a href="page.html" id="hyperlink1">Link</a>
        <ul>
             <li><a href="link.html">Link</a></li>
             <li><a href="link.html">Link</a></li>
             <li><a href="link.html">Link</a></li>
        </ul>
    </li>
</ul>

我愿使母子与id Sylink1脱钩。

Ive在 jQuery试图这样做,具体如下:

$("a#HyperLink1").click(function() { return false; });

only it seems to disable all the child links too, has anybody a better solution?

最佳回答

您应使用preventDefault(。 活动方法:

$("a#HyperLink1").click(function(e) {
    e.preventDefault();
});

这使这次活动得以通过电离层扰动;这确保了任何其他操作者为火灾听觉,但防止了发生违约行为(例如,防止为 anchor开链接,防止在<>条码>上提交表格<>。

问题回答

仅去除母子(如果它没有联系,它就应该成为一种联系):

$( #hyperlink1 ).removeAttr( href );

国际发展法也对个案敏感。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签