我有3个小div,当你点击我想在我的页面顶部播放一个更大的div时,唯一的问题是我无法让它工作,我不知道为什么。
我正在尝试更新
$('.highlight-image').on('click', function (e) {
console.log('clicked');
var currImg = $(this).find('.imageHolder').children('img').attr('src');
var currP = $(this).find('blockquote').text;
var targetImg = $('.featuredTestimonial img');
var targetName = $('.featuredTestimonial h2');
var targetP = $('.featuredTestimonial p');
$('.featuredTestimonial p').text = currP;
$('.featuredTestimonial img').attr('src'); = currImg;
});
答案 0 :(得分:3)
更改
$('.featuredTestimonial img').attr('src'); = currImg;
要
$('.featuredTestimonial img').attr('src', currImg);
答案 1 :(得分:1)
试试这个:
$('.featuredTestimonial p').text(currP);
$('.featuredTestimonial img').attr('src', currImg);
而不是
$('.featuredTestimonial p').text = currP;
$('.featuredTestimonial img').attr('src'); = currImg;
答案 2 :(得分:1)
使用它
$('.highlight-image').on('click', function(e) {
var currImg = $(this).find('.imageHolder').children('img').attr('src');
var currP = $(this).find('blockquote').text();
var targetImg = $('.featuredTestimonial img');
var targetName = $('.featuredTestimonial h2');
var targetP = $('.featuredTestimonial p');
$('.featuredTestimonial p').text(currP);
$('.featuredTestimonial img').attr('src', currImg);
});