<a> tag is a URL,but it calls functions after clicking the </a> <a> tag.How it works</a>的属性“href”

时间:2011-10-19 06:35:32

标签: jquery jquery-ui-droppable

我在jQuery UI演示中发现了这个问题。如果您下载了jQuery UI,那么它位于“demos / droppable / photo-manager.html”中。

在这个html页面中,有几个标签显示了照片div中的删除图标。这些标签的名为“href”的属性是URL,但在点击标签后会调用函数。 URL-&gt;函数?怎么做?

1 个答案:

答案 0 :(得分:0)

您可以将单击事件附加到链接,并使浏览器的默认行为为空。

HTML

<a href="http://example.com">Example</a>

的jQuery

$('a').click(function(event) {
   event.preventDefault();
   func();
});