質問

    <script>
    $(document).ready(function() {

            $('#scrollingtext').bind('marquee', function() {
                var ob = $(this);
                var tw = ob.width();
                var ww = ob.parent().width();
                ob.css({ right: -tw });
                ob.animate({ right: ww }, 20000, 'linear', function() {
                    ob.trigger('marquee');

                });
            }).trigger('marquee');

        });     


    </script>

<div id="scrollingtext"></div>

i am doing foreach with this scrollingtext div so second time it does not scroll bec. of same id.. i tried some $(this).unbind(); thing but could not solve it.. i need to scroll every id=scrollingtext inside foreach any help may save my hours..

役に立ちましたか?

解決

HTML only allows a single ID on the same page. Use a class instead. Problem solved.

<div class="scrollingtext"></div>
<div class="scrollingtext"></div>
<div class="scrollingtext"></div>
<script>
    $('.scrollingtext').bind('marquee', function() { /* .. */ });
</script>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top