views:

308

answers:

1

I would like to use jquery highlight effect to highlight a paragraph with background orange, then when completed, turn on orange background permanently. In this code the second task does not work.

myparagrah = $("#thisParagraph");

turnOrangeOnWarning("This is a warning!");

function turnOrangeOnWarning(t) {           
  myparagrah.text(t).effect("highlight",{'color':'orange'},1000);       
  myparagrah.css("background-color","orange");                      
}
+3  A: 

your function has it calling the second line immediately after the first. I imagine it is turning orange instantly, rather that a one second highlight that you want. You need to make the second line a callback to your first. Might look something like this (not sure what the correct effect() overload parameters are):

function turnOrangeOnWarning(t) {
    myparagraph.text(t).effect("highlight", {'color':'orange'}, 1000,
        function() { myparagraph.css("background-color", "orange"); }
    );
}
Tesserex