Javascript 电子商务中的产品缩放效应
我正在尝试创建这样的缩放效果 但是我试图打开Javascript 电子商务中的产品缩放效应,javascript,jquery,Javascript,Jquery,我正在尝试创建这样的缩放效果 但是我试图打开链接,而不是标记,因此我需要有关jquery的som帮助 html: 要获取超链接地址,请执行以下操作: $('li a').click(function() { var link = $(this).attr('href'); // do something with it return false; }); 这是一把你想要的小提琴 $(function() { $('li a').click(function()
链接,而不是
标记,因此我需要有关jquery的som帮助
html:
要获取超链接地址,请执行以下操作:
$('li a').click(function() {
var link = $(this).attr('href');
// do something with it
return false;
});
这是一把你想要的小提琴
$(function() {
$('li a').click(function() {
//here's the change -->
$('div img').attr('src', $(this).attr('href'));
// we change the information we take from the element to the
// href attribute of the element, $(this), which is assigned
// to the element that caused the event, the anchor tag
$('div').show();
return false;
});
$('div').mousemove(function(e){
var h = $(this).find('img').height();
var vptHeight = $(document).height();
var y = -((h - vptHeight)/vptHeight) * e.pageY;
$('div img').css('top', y + "px");
});
$('div').click(function(){
$('div').hide();
});
});
为了简洁起见,我使用了自己的demo image href属性 你也可以发布你的html吗?
@zfrisch在这里!Esster,请用HTML代码更新问题,而不是将其作为注释发布。好的,您能用缩放效果的完整代码创建一个JSFIDLE吗?@Esster您能尝试将我提供的有用答案合并到您自己的FIDLE中吗?我很乐意帮助您解决您可能遇到的任何问题。@Esster我为您提供了一把小提琴,因为我认为有时从看到学是有帮助的,但我同意Wahwah的观点,您肯定应该仔细观察,看看发生了什么变化以及它们做了什么。请随意提问。您可以实现-$(this.find('img').parent().attr('href')代码>仅使用-$(this.attr('href')代码>@wahwahwah你是对的,而且速度明显更快,所以我会更新我的答案。
$('li a').click(function() {
var link = $(this).attr('href');
// do something with it
return false;
});
$(function() {
$('li a').click(function() {
//here's the change -->
$('div img').attr('src', $(this).attr('href'));
// we change the information we take from the element to the
// href attribute of the element, $(this), which is assigned
// to the element that caused the event, the anchor tag
$('div').show();
return false;
});
$('div').mousemove(function(e){
var h = $(this).find('img').height();
var vptHeight = $(document).height();
var y = -((h - vptHeight)/vptHeight) * e.pageY;
$('div img').css('top', y + "px");
});
$('div').click(function(){
$('div').hide();
});
});