我正在使用wordpress中令人惊叹的CodaSlider为我的一个页面添加一个选项卡式功能,但是遇到了一些麻烦。
CodaSlider使用一个脚本来查看当前内容并自动定义高度,但是,我可以选择打开/关闭滑块内部的div以显示更多内容,但因为滑块已经定义了高度,所以它不会自动更新。
我的想法是添加一段JQuery来刷新滑块的div,从而显示新内容,而不必一直重新加载整个页面。
到目前为止,我得到的是:
<div class="video-centre">
<div class="video-title"> <img src="<?php echo get_bloginfo('template_url') ?>/images/video-propertiesforsale.jpg" alt="properties for sale" /> </div>
<div class="video-point"> <img src="<?php echo get_bloginfo('template_url') ?>/images/video-point.jpg" alt="video pointer" /> </div>
<div class="video-thumb">
<div class="coda-slider" id="slider-id">
<div>
<h2 class="title"><span>Crouch End</span></h2>
<?php the_field('crouch_end'); ?>
<p class="video-more2"><a href="javascript:animatedcollapse.show(['expandable-2'])" id="refresh">View More</a></p>
<div id="expandable-2">
<?php the_field('properties_for_sale_hidden'); ?>
<p class="video-close2"><a href="javascript:animatedcollapse.hide(['expandable-2'])" id="refresh">Close</a></p>
</div>
</div>
<script>
var $r = jQuery.noConflict();
$r(function() {
$r("#refresh").click(function(evt) {
$r(".panel").load("index.php")
evt.preventDefault();
})
})
</script>我遇到的问题是,脚本加载的是整个页面,而不是它应该加载的实际内容,而且我似乎无法让它做我想要的事情。
我希望上面的话是可以理解的,它在我的脑海里听起来很好:
发布于 2012-09-19 00:10:00
是的,.load旨在加载页面的全部内容。您可以运行.load,然后遍历子进程来获得您想要的:
var div = $('<div/>').load('index.php');
$('.panel').replaceWith(div.find('.panel'));https://stackoverflow.com/questions/12480789
复制相似问题