Change css property in chain - JavaScript

Posted by SilverDeveloper on Stack Overflow See other posts from Stack Overflow or by SilverDeveloper
Published on 2012-06-02T22:22:13Z Indexed on 2012/06/02 22:40 UTC
Read the original article Hit count: 171

Filed under:
|
|

I'm using MooTools 1.4.5 and I want to change cursor before calling function that takes some time and after finished same function set cursor to default. I was not successful.

After that I made simple example to change background color via plain JavaScript (no jQuery or MooTools plugin) and again I was not successful.

Here is my code.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
    <script type="text/javascript">
    <!--
        document.body.style.background = 'red';
        setTimeout(function () {  }, 1250);
        document.body.style.background = 'yellow';
    //-->    
    </script>
</html>

First at all I set background color to red, and after delay to yellow. I assumed that the background color will bi set to red and after delay to yellow. It doesn't work. When page is loaded background color is yellow (last line). If I insert alert function in a middle of lines where sets background color everything works fine (background color is red, click to message box, background color is yellow). Why it works so? Only last changing style is affected. I need something like that to change pointer before calling function that takes 10 seconds and setting cursor to default value after function is done.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css