我无法获取内容'当用户点击' span3 a'打开它之后。
它淡出并隐藏div一瞬间。如何正确定位span3 a以便在打开后关闭内容?
$(".span3").on('click', 'a', function (e) {
var href;
e.preventDefault();
href = $(this).attr("href");
$(".team-loop").find("a").removeClass("active");
$(this).addClass("active");
$('#staff_expand').fadeOut().hide();
$(".content").load(href + " #staff_expand");
});
HTML结构:
<div class="content border-bottom" > </div>
<div class="row-fluid">
<ul class="team-loop">
<?php $args = array( 'post_type' => 'team', 'posts_per_page' => 30 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<li class="span3 mobile_width"><a href="' . get_permalink() . '">';
the_content();
echo '<span class="staff_names"><span class="plus"> + </span>';
the_title();
echo '</span></a></li>';
endwhile;
?>
</ul>
</div>
然后从网址中提取的部分是:
<div class="row-fluid" id="staff_expand">
<div class="span3">
<?php echo $content; ?>
</div>
<div class="span3">
<div><?php echo $title; ?></div>
<div><?php echo $email; ?></div>
<div><?php echo $number; ?></div>
<div><?php echo $linkedin; ?></div>
<div class="add_to_contacts"><?php echo $addcontact; ?></div>
</div>
<div class="span6">
<div class="desc"><?php echo $text1; ?></div>
<div class="desc"><?php echo $text2 ;?></div>
</div>
</div>
答案 0 :(得分:0)
$(".span3").on('click', 'a', function (e) {
e.preventDefault();
var href = $(this).attr("href");
$(".team-loop").find("a").removeClass("active");
$(this).addClass("active");
$('.content').fadeOut(400, function() {
$(this).load(href + " #staff_expand", function() {
$(this).fadeIn(400);
});
});
});