jQuery用另一个div函数替换div

时间:2014-08-15 12:06:28

标签: javascript jquery html css

我有这个HTML块,我需要一个jQuery函数(比如replaceWith())来查找当前四个中<div class="tagstrap">的下一个实例,并在调用我的javascript方法时更改它。我想使用jQuery bxslider onSlideAfter()方法执行此操作。有人可以帮助我使用javascript函数吗?

HTML

<div class="tagstrap">
<h2><p>We provide business and personal insurance to suit your individual needs</p></h2>
<a class="read-more" href='products/'>Read More</a>
</div>

<div class="tagstrap">
<h2><p>Smallholders Insurance</p></h2>
<a class="read-more" href='products/smallholders.php'>Read More</a>
</div>

<div class="tagstrap">
<h2><p>Single tractor</p></h2>
<a class="read-more" href='products/single-tractor.php'>Read More</a>
</div>

<div class="tagstrap">
<h2><p>Property Owners</p></h2>
<a class="read-more" href='products/property-owners.php'>Read More</a>
</div>  

Javascript(适用于bxSlider)

    $('.bxslider').bxSlider({
            pager: true, 
            auto: true,
            useCSS: false
            onSlideAfter: function($slideElement, oldIndex, newIndex){//my method here}
        });

1 个答案:

答案 0 :(得分:0)

$('.bxslider').bxSlider({
        pager: true, 
        auto: true,
        useCSS: false
        onSlideAfter: function(){
           $('.tagstrap').each(function(){
              $(this).html("Your replacement code goes here...");
           });
        }
    });