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 () { .... }
精彩评论