首先让我们实现 Helloworld。当网页加载之后,显示一个提示框,内容为 Hello, world

在文档载入后,马上执行代码,可以通过 document 对象的 ready 事件来完成。

取得 document 对象的方法非常简单,$( document ),如下就可以取得document 对象的 ready 事件 $( document ).ready

让我们完成它。这个页面在文档载入之后会弹出一个对话框,并显示Hello, world

<html>

         <head>

                   <title>Hello</title>

<script src="jquery-1.2.5.js" type="text/javascript"></script>

<script type="text/javascript">

$(document).ready( function() {

                                               alert( "Hello, world." );

} );

</script>

         /head>

         </body>

         </body>

</html>

由于 document 对象的 ready 事件非常常用,它还可以简化为 $(   ),上述代码也可以如下完成。

<html>

         <head>

                   <title>Hello</title>

<script src="jquery-1.2.5.js" type="text/javascript"></script>

<script type="text/javascript">

$( function() {

                                               alert( "Hello, world." );

} );

</script>

         /head>

         </body>

         </body>

</html>

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2021-06-17
  • 2021-12-11
  • 2022-12-23
  • 2021-12-18
  • 2022-02-19
  • 2021-10-02
猜你喜欢
  • 2022-01-13
  • 2021-07-29
  • 2021-11-30
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2022-01-15
相关资源
相似解决方案