JS script type partial attribute value analysis

Source: Internet
Author: User

1. Text/javascript:

(1) <script type= "Text/javascript" src= "js/jquery-1.10.2.min.js" ></script>---referencing external Js

(2) Coded JS code

2.text/template&&text/html

  1  <script id= "commenttemplate" type= "text/template" > 2  <li> 3  <div class=" Photo "> 4  <a href= "#" > 5  </a> 6  </div> 7  <p> 8  <a href= "#" >[ Username]:</a><span class= "Time" >[createdate]</span> 9  & Lt;/p>10  <div class= "clear" >11 </div>12  </li>13  </script> 
1<div id= "Comment_ul_2" >2</div>3<input type= "button" id= "Addfun" value= "click Me"/>4<script type= "Text/javascript" >5             varReg =NewREGEXP ("\\[" ([^\\[\\]]*?) \ \] ", ' IgM ');//I g m is used to specify case-sensitive matches, global matches, and multiline matches, respectively. 6$ ("#addFun"). Click (function () {7                 varhtml = document.getElementById ("Commenttemplate"). InnerHTML;8                 varSource = Html.replace (Reg,function(node, key) {return{' userimg ': ' 1 ', ' UserName ': ' Zhang ', ' createdate ': ' 2011-1-1 '}[key]; });9$ ("#comment_ul_2"). append (source);Ten             }); One  A             varZzl = "Name:[name]"; -Zzl = Zzl.replace (Reg,function(node, key) {return{' name ': ' Occupied '}[key]; }); -             //alert (ZZL); the  -</script>

3.type= "Text/x-handlebars-template"

<div id= "List" > </div> <script type= "Text/javascript" src= "Js/handlebars.js" &GT;&LT;/SCRIPT&G        T <script id= "People-template" type= "Text/x-handlebars-template" >{{#people}}<div class= "Person" > $ (document). Ready (function () {                //Compile our template                varTemplate = Handlebars.compile ($ ("#people-template"). HTML ()); vardata ={people: [{first_name:"Rui", Last_Name: "Fengyun", Phone: "1234567890", email: "[email protected]", Member_since: "Mar 25, 2011"}, {first_name:"Allison", last_name: "House", Phone: "0987654321", email: "[email protected]", Member_since: "Jan 13, 2011"}, {first_name:"Nick", last_name: "Pettit", Phone: "9836592272", email: "[email protected]", Member_since: "Apr 9, 2009"}, {first_name:"Jim", last_name: "Hoskins", Phone: "7284927150", email: "[email protected]", Member_since: "May 21, 2010"}, {first_name:"Ryan", last_name: "Carson", Phone: "8263729224", email: "[email protected]", Member_since: "Nov 1, 2008" }                    ]                }; $(' #list '). HTML (template (data));        }); </script>

JS script type partial attribute value analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.