cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              	<h2>第四章 控制器和状态</h2>
  <div id="users">
      <input type="search" value="" placeholder="Enter a query">

               (function($, exports){
      var mod = {};
      mod.create = function(includes){
        var result = function(){
          this.initializer.apply(this, arguments);
          this.init.apply(this, arguments);
        result.fn = result.prototype;
        result.fn.init = function(){};
        result.proxy    = function(func){ return $.proxy(func, this); };
        result.fn.proxy = result.proxy;

        result.include = function(ob){ $.extend(this.fn, ob); }; 
        result.extend  = function(ob){ $.extend(this, ob); };
          initializer: function(options){
            this.options = options;
            for (var key in this.options)
              this[key] = this.options[key];

            if (this.events) this.delegateEvents();
            if (this.elements) this.refreshElements();
          $: function(selector){
            return $(selector, this.el);

          refreshElements: function(){
            for (var key in this.elements) {
              this[this.elements[key]] = this.$(key);

          eventSplitter: /^(\w+)\s*(.*)$/,

          delegateEvents: function(){
            for (var key in this.events) {
              var methodName = this.events[key];
              var method     = this.proxy(this[methodName]);

              var match      = key.match(this.eventSplitter);
              var eventName  = match[1], selector = match[2];

              if (selector === '') {
                this.el.bind(eventName, method);
              } else {
                this.el.delegate(selector, eventName, method);
        if (includes) result.include(includes);
        return result;
      exports.Controller = mod;
    })(jQuery, window);
    var exports = this;
      exports.SearchView = Controller.create({
        elements: {
          "input[type=search]": "searchInput",
          "form": "searchForm"
        events: {
          "submit form": "search"
        init: function(){ /* ... */ },
        search: function(){
          alert("Searching: " + this.searchInput.val());
          return false;
      new SearchView({el: $("#users")});
Loading ..................