Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>eleTree</title>
  <link rel="stylesheet" href="//unpkg.com/eletree/dist/css/icon.css"  type="text/css">
</head>
<body>
	<div class="eletree"></div>
	<script src="//unpkg.com/eletree/dist/eleTree.js"></script>
</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                var data = [
  {
    "label": "安徽省",
    "id": "001",
    "isOpen": true,
    "children": [
      {
        "label": "淮北市",
        "id": "001001"
      },
      {
        "label": "马鞍山市",
        "id": "001002",
        "isOpen": true,
        "children": [
          {
            "label": "花山区",
            "id": "001002001",
            "isOpen": true,
            "children": [
              {
                "label": "霍里街道",
                "disabled": true,
                "checked": true,
                "id": "001002002001",
                "radioDisabled": true
              },
              {
                "label": "桃源路",
                "id": "001002002002"
              },
              {
                "label": "湖东路",
                "checked": true,
                "id": "001002002003",
                "radioChecked": true
              }
            ]
          },
          {
            "label": "雨山区",
            "id": "001002002"
          },
          {
            "label": "和县",
            "id": "001002003"
          }
        ]
      },
      {
        "label": "合肥市",
        "id": "001003"
      }
    ]
  },
  {
    "label": "河南省",
    "id": "002",
    "children": [
      {
        "label": "郑州市",
        "id": "002001"
      },
      {
        "label": "开封市",
        "id": "002002"
      }
    ]
  },
  {
    "label": "江苏省",
    "id": "003",
    "children": [
      {
        "label": "苏州市",
        "id": "003001"
      },
      {
        "label": "南京市",
        "id": "003002"
      },
      {
        "label": "无锡市",
        "id": "003003"
      },
      {
        "label": "徐州市",
        "id": "003004"
      }
    ]
  }
]

var ele = eleTree({
  el: '.eletree',
  data: data,
  showCheckbox: true,
  highlightCurrent: true,
  showRadio: true,
  imgUrl: "//unpkg.com/eletree/dist/images/",
  icon: {
    fold: "fold.png",
    leaf: "leaf.png",
    checkFull: ".eletree_icon-check_full",
    checkHalf: ".eletree_icon-check_half",
    checkNone: ".eletree_icon-check_none",
    dropdownOff: ".eletree_icon-dropdown_right",
    dropdownOn: ".eletree_icon-dropdown_bottom",
    loading: ".eleTree-animate-rotate.eletree_icon-loading1",
    radioCheck: "radioCheck.png",
    radioCheckNone: "radioCheckNone.png",
  }
})
ele.on('checkbox', function(data) {
  // console.log(this)
  console.log(data)
})
ele.on('radio', function(data) {
  // console.log(this)
  console.log(data)
})
ele.on('click', function(data) {
  // console.log(this)
  console.log(data)
})
              
            
!
999px

Console