Jquery 如何将div中的图像放入图像标记中?
我有一个真正的问题。我正在为WordPress制作一个主题。在一个班级里,我有一个大尺寸的缩略图。我想做一些像这样的事情:Jquery 如何将div中的图像放入图像标记中?,jquery,Jquery,我有一个真正的问题。我正在为WordPress制作一个主题。在一个班级里,我有一个大尺寸的缩略图。我想做一些像这样的事情: $("#big-gal-img").attr("src", $(this).children('.mgallery-image-big').val()); 当用户单击我的类时,我想将该类中的图片放入图像标记中。 像这样的事情: $("#big-gal-img").attr("src", $(this).children('.mgallery-image-big'
$("#big-gal-img").attr("src", $(this).children('.mgallery-image-big').val());
当用户单击我的类时,我想将该类中的图片放入图像标记中。
像这样的事情:
$("#big-gal-img").attr("src", $(this).children('.mgallery-image-big').val());
这是我的完整代码:
<?php get_header();?>
<div id="big-gal-div">
<div id="back-gal">
</div>
<img id="big-gal-img">
</div>
<center>
<div id="mgallery">
<div class="mGallery-Box">
<?php query_posts ('');?>
<?php if(have_posts()) :?>
<?php while(have_posts()) : the_post();?>
<div id="mone-in-gallery">
<div class="mgallery-title">
<a >
<span><?php the_title(); ?></span>
</a>
</div>
<div class="mgallery-image" title="<?php the_title(); ?>"><a>
<?php the_post_thumbnail();?>
</a>
</div>
<div class="mgallery-image-big"><a>
<img class="mgallery-image-big" src="<?php the_post_thumbnail( full );?>">
</a>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query();?>
</div>
</div>
</center>
<script>
$(document).ready(function(){
$('.mgallery-image-big').hide();
$('#big-gal-div').hide();
$('#big-gal-img').click(function(){
$('#big-gal-div').hide();
});
$('#mone-in-gallery').click(function(){
var image_url = $('#mgallery-image-big').html();
$("#big-gal-img").attr("src", $(this).children('.mgallery-image-big').val());
$('#big-gal-div').show();
});
});
</script>
<?php get_footer();?>
">
$(文档).ready(函数(){
$('.mgallery image big').hide();
$('big gal div').hide();
$('big gal img')。单击(函数(){
$('big gal div').hide();
});
$(“#图库中的货币”)。单击(函数(){
var image_url=$('#mgallery image big').html();
$(“#big gal img”).attr(“src”,$(this).children('.mgallery image big').val());
$('big gal div').show();
});
});
这似乎是一个XY问题……您真正想解决的是哪个问题?这似乎只是解决该问题的一种方法。我将添加完整的代码。