0

ねえ、私は jTicker を使用して、ユーザー入力に反応できるメッセージを言おうとしています。jTicker の動作方法は、html 要素タグ間のテキストに影響します。

この例では、jQuery を使用して、ティッカーされている特定のタグ セット間のテキストを変更しようとしています。jTickerによる。問題は、テキストを変更しようとするたびに、jTicker はページが最初に読み込まれたときにタグの間にあったテキストのみを使用し、新しいテキストは使用しないことです。jTicker が影響しているテキストをその場で変更できるように、このコードを修正するにはどうすればよいですか?

Javascript:

<script src="jquery.jticker.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $("#messageId").ticker({
            rate: 40,
            delay: 900,
            transition: "fade",
        });
        $(".stop").click(function(){
            $("#messageId").trigger("stop");
            return false;
        });
        $(".play").click(function(){
            $("#messageId").trigger("play");
            return false;
        }); 
    });

function test() {
    $('#theMessage').text('New text!');
}
</script>

HTML:

<body>
    <div id="messageId">
        <p id="theMessage">Old text</p>
    </div>
    <div>
        <input type="button" value="Test"
        class="play" onClick="test();" />
    </div>
</body>
4

1 に答える 1

0
function test() {
    $('#theMessage').text($("#messageId").text());
}
于 2013-02-27T02:41:27.713 に答える