Last active
June 7, 2016 09:44
-
-
Save z2015/4e750bf4efcd373f5dca8bd413d8cbc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function easyTab(tab, content){ | |
| return this instanceof easyTab ? this.init(tab, content) : new easyTab(tab, content); | |
| }; | |
| easyTab.prototype.init = function(tab, content) { | |
| this.el = { | |
| tab: tab, | |
| content: content | |
| }; | |
| document.querySelector(this.el.tab).addEventListener('click', this, false); | |
| }; | |
| easyTab.prototype.handleEvent = function(e) { | |
| e.preventDefault(); | |
| var ele = e.target; | |
| var tag = e.target.tagName; | |
| if (tag == 'I'){ | |
| ele = e.target.parentNode; | |
| } | |
| $(this.el.tab + ' span').removeClass('active'); | |
| $(ele).addClass('active'); | |
| var tab = ele.parentNode.getAttribute('data-tab'); | |
| $(this.el.content + '>li').removeClass('active'); | |
| $(this.el.content + '>li').eq(tab).addClass('active'); | |
| } | |
| easyTab('.order-nav', '.order-detail-content-wrap'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment