0

Hey so I'm trying to use jTicker to say messages that can react to user input. The way jTicker works, it affects text between html element tags.

In this example, I'm trying to use jQuery to modify the text between a certain set of tags that is being tickered? by jTicker. The problem is that whenever I try to change the text, jTicker only uses the text that was between the tags when the page first loaded and not the new text. How can I fix this code so that the text that jTicker is affecting can be changed on the fly?

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>

1 Answers1

0
function test() {
    $('#theMessage').text($("#messageId").text());
}
Tutan Ramen
  • 1,234
  • 1
  • 8
  • 27
  • That didn't seem to change much. It seems to just put it in a loop and thus reuse the same "Old text", which is the problem it was having already. Also, where would I define the new text? –  Feb 27 '13 at 20:15