小编Jos*_*osa的帖子

在身体加载javascript上调用函数?

可能的重复:
加载页面时运行函数

我的身体内部有一个脚本,一个相对较长的脚本,我想把它放在一个单独的 .js 文件中,然后只在身体加载时调用该函数,而不是将脚本放在正文中,但我不知道如何称它为。帮助?

脚本:

            <script type="text/javascript">
            // Set the number of snowflakes (more than 30 - 40 not recommended)
     var snowmax = 35

     // Set the colors for the snow. Add as many colors as you like
     var snowcolor = new Array("#ddddff", "#ccccdd", "#f3f3f3", "#f0ffff")

     // Set the fonts, that create the snowflakes. Add as many fonts as you like
     var snowtype = new Array("Times", "Arial", "Times", "Verdana")

     // Set the letter that creates your snowflake (recommended: * …
Run Code Online (Sandbox Code Playgroud)

javascript onload

5
推荐指数
2
解决办法
5万
查看次数

如何控制document.write写入的位置

我想让我的javascript从数组中打印一个随机引用.我设法做到了这一点,但不知道如何控制写入的位置.我希望在div中写出来.救命?

码:

quotes = [];
quotes[0] = "I have a new philosophy. I'm only going to dread one day at a time.";
quotes[1] = "Reality is the leading cause of stress for those in touch with it.";
quotes[2] = "Few things are harder to put up with than the annoyance of a good example.";
quotes[3] = "The pure and simple truth is rarely pure and never simple.";
quotes[4] = "There's no business like show business, but there are several businesses …
Run Code Online (Sandbox Code Playgroud)

javascript

1
推荐指数
1
解决办法
673
查看次数

jQuery在jsfiddle中工作,但不在html文件中?

我检查了很多次,但我不知道为什么jQuery不会工作.它适用于jsfiddle!

HTML:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Josue Espinosa</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="animate.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"
        type="text/javascript"></script>
</head>
<body>
<div id="menu">

</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

CSS:

#menu{
    width:15px;
    height:200px;
    background:red; 
}
Run Code Online (Sandbox Code Playgroud)

jQuery的:

$('#menu').hover(function(){
     $("#menu").stop().animate({width : "300px"});
});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

1
推荐指数
1
解决办法
608
查看次数

如果width == 200px运行函数

这是一个显示问题jsFiddle

我不确定为什么这不起作用:

if ($('#menu').width() == '200px') {
    alert("what");
}
Run Code Online (Sandbox Code Playgroud)

我希望在动画完成时显示警报.所以我假设我可以说,因为当动画完成时,元素的宽度为200px,它会显示警告.

javascript jquery

1
推荐指数
1
解决办法
115
查看次数

标签 统计

javascript ×4

jquery ×2

html ×1

onload ×1