问题
I found this question in jQuery UI demos.If you downloaded the jQuery UI,and so it located in "demos/droppable/photo-manager.html".
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?
回答1:
You can attach a click event to a link and null the browser's default behaviour.
HTML
<a href="http://example.com">Example</a>
jQuery
$('a').click(function(event) {
event.preventDefault();
func();
});
来源:https://stackoverflow.com/questions/7817422/the-attribute-href-of-a-a-tag-is-a-url-but-it-calls-functions-after-clicking