属性"href" < a>标签是一个URL,但是在点击< a>标签.它是如何工作的 [英] the attribute "href" of a <a> tag is a URL,but it calls functions after clicking the <a> tag.How it works

查看:100
本文介绍了属性"href" < a>标签是一个URL,但是在点击< a>标签.它是如何工作的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I found this question in jQuery UI demos.If you downloaded the jQuery UI,and so it located in "demos/droppable/photo-manager.html".

在此html页面中,有几个标签显示了照片div中的删除图标.这些标签的名为"href"的属性是URL,但单击标签后会调用函数. URLs-> functions?如何执行?

In this html page,there were several tags showing the delete icons in photo div.These tags' property named "href" are URLs,but it would call functions after clicking the tags. URLs->functions?How to do that?

推荐答案

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

You can attach a click event to a link and null the browser's default behaviour.

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

jQuery

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

这篇关于属性"href" &lt; a&gt;标签是一个URL,但是在点击&lt; a&gt;标签.它是如何工作的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆