Daily Archives: 2011 年 04 月 20 日

Hello World

jquery模板方法

偶然发现了jquery模板方法tmpl(),看起来还不错:

<ul id="movieList"></ul>
<script id="movieTemplate" type="text/x-jquery-tmpl">
    <li><b>${Name}</b> (${ReleaseYear})</li>
</script>
<script type="text/javascript">
    var movies = [
        { Name: "The Red Violin", ReleaseYear: "1998" },
        { Name: "Eyes Wide Shut", ReleaseYear: "1999" },
        { Name: "The Inheritance", ReleaseYear: "1976" }
    ];
    $( "#movieTemplate" ).tmpl( movies )
         .appendTo( "#movieList" );
</script>

转自:http://api.jquery.com/tmpl/

Hello World

Javascript 的private, public 属性和方法

         function Base() {
                // private attribute
                var i = 2;
 
                // public attribute
                this.k = 3;
 
                // private method
                function setI(j) {
                    i = j;
                }
 
                // public method
                this.resetI = function() {
                    setI(0);
                };
 
 
                // public method
                this.getI = function() {
                    return i;
                }
            }
 
            // public attribute
            Base.prototype.j = 1;
 
            // static attribute
            Base.l = 4;
 
            // public method
            Base.prototype.getJ = function() {
                return this.j;
            };
 
            // static method
            Base.setL = function(m) {
                Base.l = m;
            }

转自:http://sinkiangcai.blog.163.com/blog/static/77664420084702020485/