JavaScript 函数

来源:互联网 发布:管家婆数据库在哪里 编辑:程序博客网 时间:2024/06/01 09:13
编程语言经常依赖键/值对。函数有名字updateMessage,其值即代码段(由语句组成)。当通过函数名调用函数时,这些语句就会执行。<!DOCTYPE html><html>    <head>        <title>Basic Function</title>        <link rel="stylesheet" href="css/c03.css" />    </head>    <body>        <h1>TravelWorthy</h1>        <div id="message">Welcome to our site!</div>        <script type="text/javascript">            var msg = 'Sign up to receive our newsletter for 10% off!';            function updateMessage(){                var el = document.getElementById('message');                el.textContent = msg            }            updateMessage();        </script>    </body></html>

0 0
原创粉丝点击