/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.fn.setOuterWidth = function(px) { var width = px - parseFloat(this.css('padding-left')) - parseFloat(this.css('padding-right')) - parseFloat(this.css('border-left-width')) - parseFloat(this.css('border-right-width')) return this.css('width', width + 'px') } $.fn.getOffsetRight = function() { return Math.round(this.outerWidth() + this.offset().left) } $.fn.getOffsetBottom = function() { return Math.round(this.outerHeight() + this.offset().top) } $.fn.isChildOf = function(node) { if (node instanceof $) { node = node[0] } if (!node) { return false } var child, i for (i = 0; i < this.length; i++) { child = this[i] do { child = child.parentNode if (child == node) { return true } } while (child) } return false }