Last active
August 31, 2016 16:58
-
-
Save ABM-Dan/7154d914c8b62fa9b029c987865cbb3a 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($) { | |
return $.fn.extend({ | |
findLabel: function() { | |
var matched; | |
matched = []; | |
this.each(function() { | |
var $label, $this, id; | |
$this = $(this); | |
id = $this.attr('id'); | |
if (id != null) { | |
$label = $('label[for=\'' + id + '\']'); | |
} | |
if (($label == null) || $label.length === 0) { | |
$label = $this.closest('label'); | |
} | |
return matched.push($label); | |
}); | |
return $(matched); | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment