Skip to content

brainedia/jquery-subordinate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Subordinate

$.subordinate() is a combination of $.append() and $.find().

It appends an element but returns this new created jQuery object. That makes your code way much shorter and cleaner, when building complex DOM structures on-the-fly.

Example

Here's a Demo

How to use

Short

$('body')
  .subordinate( '<div id="parent"></div>' )
  .subordinate( '<h1>Headline</h1>' );

Shorter: defining tags by CSS-like selectors

$('body')
  .subordinate( 'div#parent' )
  .subordinate( 'h1', "Another headline" );

Ultimate way: sequence of definitions

$('body').subordinate( 'div#parent > p.child > span', "I like!" );