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-10-17 08:31:31