[JQ权威指南]getScript函数获取数据

HTML:


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>getScript函数获取数据title>
    <script type="text/javascript" 
            src="Jscript/jquery-1.4.2-vsdoc.js">
    script>
    <script type="text/javascript" 
            src="Jscript/jquery-1.4.2.js">
    script>
    <style type="text/css">
           body{font-size:13px}
           .divFrame{width:260px;border:solid 1px #666}
           .divFrame .divTitle{padding:5px;background-color:#eee}
           .divFrame .divContent{padding:8px}
           .divFrame .divContent .clsShow{font-size:14px}
           .btn {border:#666 1px solid;padding:2px;width:80px;
           filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#ffffff, EndColorStr=#ECE9D8);}
    style>
    <script type="text/javascript">
        $(function () {
            $("#Button1").click(function () {
                $.getScript("UserInfo.js");
            })
        })
    script>
head>
<body>
   <div class="divFrame">
         <div class="divTitle">
              <input id="Button1" type="button" 
                     class="btn" value="获取数据" />
         div>
         <div class="divContent">
              <div id="divTip">div>
         div>
    div>
body>
html>

JS:
var data = [
{
“name”: “龚德辉”,
“sex”: “男”,
“email”: “[email protected]
},
{
“name”: “李建洲”,
“sex”: “女”,
“email”: “[email protected]
}
];

var strHTML = “”; //初始化保存内容变量
$.each(data, function() { //遍历获取的数据
strHTML += “姓名:” + this[“name”] + “
”;
strHTML += “性别:” + this[“sex”] + “
”;
strHTML += “邮箱:” + this[“email”] + “


”;
})
$(“#divTip”).html(strHTML); //显示处理后的数据

你可能感兴趣的:(前端设计,JQuery)