Posted By

kendsnyder on 09/17/11


Tagged

plugin jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


jQuery sizing tools


 / Published in: jQuery
 

  1. $.fn.setOuterWidth = function(px) {
  2. var width = px -
  3. parseFloat(this.css('padding-left')) -
  4. parseFloat(this.css('padding-right')) -
  5. parseFloat(this.css('border-left-width')) -
  6. parseFloat(this.css('border-right-width'))
  7. return this.css('width', width + 'px')
  8. }
  9. $.fn.getOffsetRight = function() {
  10. return Math.round(this.outerWidth() + this.offset().left)
  11. }
  12. $.fn.getOffsetBottom = function() {
  13. return Math.round(this.outerHeight() + this.offset().top)
  14. }
  15. $.fn.isChildOf = function(node) {
  16. if (node instanceof $) {
  17. node = node[0]
  18. }
  19. if (!node) {
  20. return false
  21. }
  22. var child, i
  23. for (i = 0; i < this.length; i++) {
  24. child = this[i]
  25. do {
  26. child = child.parentNode
  27. if (child == node) {
  28. return true
  29. }
  30. }
  31. while (child)
  32. }
  33. return false
  34. }

Report this snippet  

You need to login to post a comment.