Created
November 30, 2012 06:48
-
-
Save qhwa/4174179 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
| // file: src/grunt-demo-1.js | |
| (function($) { | |
| var ALI_LINK_REG = /^http:\/\/(.+\.)?alibaba\.com/; | |
| // Collection method. | |
| $.fn.alilink = function() { | |
| return this.each(function() { | |
| var self = $(this); | |
| if( isAliLink(this) ){ | |
| self.addClass('ali-link'); | |
| } else { | |
| self.removeClass('ali-link'); | |
| } | |
| }); | |
| }; | |
| // Custom selector. | |
| $.expr[':'].alilink = function(elem) { | |
| return isAliLink(elem); | |
| }; | |
| function isAliLink(el) { | |
| return /A/i.test(el.tagName) && ALI_LINK_REG.test(el.href); | |
| } | |
| }(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment