Sha256: 7d0d624eb1d2097301defc9d598060f8d6a9657dcfd8b5ad486e3108b9a8a6a2

Contents?: true

Size: 463 Bytes

Versions: 2

Compression:

Stored size: 463 Bytes

Contents

// Example usage: $('.alert.dismissible').getOrAddChild('.close', '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>');

$.fn.getOrAddChild = function (selector, html) {
  var $parents = this;
  $parents.each(function() {
    var $parent = $(this);
    var $child = $parent.children(selector);
    if (!$child.length)
      $child = $(html).appendTo($parent);
    return $child;
  });
};

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
colorgy_style-0.0.0.4 assets/javascripts/colorgy/lib/jquery.getOrAddChild.js
colorgy_style-0.0.0.2 assets/javascripts/colorgy/lib/jquery.getOrAddChild.js