0

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");                      
}

1 Answer 1

3

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"); }
    );
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.