js方法:
<script type="text/javascript">
window.onload = function(){
var userName = "xiaoming";
alert(userName);
}
</script>
jQuery方法:
<script type="text/javascript">
$(document).ready(function{
var userName = "xiaoming";
alert(userName);
})
或者简写:
$(function{
var userName = "xiaoming";
alert(userName);
})
</script>
时间: 2024-12-20 02:10:29