Created
September 15, 2014 06:22
-
-
Save lelinhtinh/3e8a217a08388aa2002e to your computer and use it in GitHub Desktop.
Kiểm tra xem phần tử có tồn tại hay chưa
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
// Tiny jQuery Plugin | |
// by Chris Goodchild | |
$.fn.exists = function(callback) { | |
var args = [].slice.call(arguments, 1); | |
if (this.length) { | |
callback.call(this, args); | |
} | |
return this; | |
}; | |
// Usage | |
$('div.test').exists(function() { | |
this.append('<p>I exist!</p>'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment