Nick Reeve
Nick Reeve

Reputation: 1680

Change text during jQuery Highlight effect

Is there any way of changing the text of a div whilst a highlighting effect is taking place, and then revert back to the original text once it has finished?

Code for initiating the highlight effect:

$("#myDiv").effect("highlight", {}, 3000);

Upvotes: 1

Views: 633

Answers (1)

rahul maindargi
rahul maindargi

Reputation: 5655

Try this.

   var myDiv=$("#myDiv");
    myDiv.data("old",myDiv.html());
    myDiv.html("New text");
    myDiv.effect("highlight", {}, 3000, callback);

    function callback(){
        var myDiv=$("#myDiv");
        myDiv.html(myDiv.data("old"));
    }

Demo

Upvotes: 2

Related Questions