我有这个问题:
我有一些用 jquery 动画的 div,我需要其中的一些链接。我把链接放在普通的“html a href's”中。
有没有办法让这成为可能?我已经在网上搜索了两天,甚至问了一位网页设计老师,但我们找不到任何有用的东西。
这是我正在处理的网站:
http://designchitchat.be/bart/vuurdood-site/
提前致谢!
据我了解。你可以这样做。
<div style="width:100px;height:100px">
<a href="http://somesite.com" style="display:inline-block;width:100%;height:100%"></a>
</div>
萨沙,我得到了他想要的。他提供了一些关于 'DISCOGRAFIE' 和 'BIO' 板的信息,这些板在点击后由于 jquery 的动画效果而滑动。我想,他想把链接放在这些块上。但点击后,动画被触发而不是调用超链接点击事件。
这可以通过所有所需链接的 onHover 效果来实现。由于动画块正在使用 onClick 事件。为此,只需在 jQuery 的 document.ready 中添加以下代码。
$("a").hover(function(){
var link=$(this).attr('href');
location.redirect(link);
});
您必须测试目标是否是“a”元素
我做了一个jsfiddle,你可以测试我放在“链接”框中的链接
你也可以测试这个javascript,它只适用于“链接”框,你必须复制其他部分
$(document).ready(function() {
$('#kogelclip').draggable();
$('#vulpen').draggable();
$('#bio').toggle(function() {
$(this).animate({
top: '+=390'
}, {
duration: 750,
easing: 'swing'
});
}, function() {
$(this).animate({
top: '-=390'
}, {
duration: 750,
easing: 'swing'
});
});
$('#discografie').toggle(function() {
$(this).animate({
left: '+=560'
}, {
duration: 750,
easing: 'swing'
});
}, function() {
$(this).animate({
left: '-=560'
}, {
duration: 750,
easing: 'swing'
});
});
$('#links').toggle(function(event) {
if (!$(event.target).is('a')) {
$(this).animate({
right: '+=560'
}, {
duration: 750,
easing: 'swing'
});
} else {
document.location.href = $(event.target).attr('href');
}
}, function(event) {
if (!$(event.target).is('a')) {
$(this).animate({
right: '-=560'
}, {
duration: 750,
easing: 'swing'
});
} else {
document.location.href = $(event.target).attr('href');
}
});
});