开发者

Why am I getting this error "block is not defined"?

开发者 https://www.devze.com 2023-04-04 21:58 出处:网络
I am getting this javascript error: \"block is not define开发者_开发百科d\" <script type=\"text/javascript\">

I am getting this javascript error: "block is not define开发者_开发百科d"

<script type="text/javascript">
$(document).ready(function()
{
  $(".register_now").click(function()
  {

    $(".fp_top_right_login").slideToggle(600);
    var st = document.getElementById("fp_top_right_register").style.display;
    if(st == "" || st == "none")
    {
      window.setTimeout(document.getElementById("fp_top_right_register").style.display="block",600); //error happens here
    }
    else
    {
      window.setTimeout(document.getElementById("fp_top_right_register").style.display="none",600); //and also here
    }
  });
});
</script>


setTimeout takes a function as a parameter. You can use an anonymous function. Example:

window.setTimeout(function() {
    document.getElementById("fp_top_right_register").style.display="block"; 
}, 600);


There is an error in you way of using setTimeout.

window.setTimeout(function(){document.getElementById("fp_top_right_register").style.display="block"},600);

Also, consider using jquery css :

$('#fp_top_right_register').css('display','block');


The first argument to window.setTimeout should be a function, not a string, which is the result of your assignment.

You probably wanted to wrap that assignment in

function () { .... }
0

精彩评论

暂无评论...
验证码 换一张
取 消