.addParent( "Parent_Tag_Name" [, Properties ] [, Position ] ) - Add a Parent element
.addParent() will append a parent element to a child. It can set attributes to the parent using the Properties parameter. Parents can be attached more than one level up from the target element using position parameter.
Parameters
NameTypeDefaultPossible ValuesDescription
Parent_Tag_NameStringTag NamesParent tag names
PropertiesJSONOptionalAttributes for Elements Attribute names and values will be set for the new parent element. "text" property will set inner Text content.
PositionNumberOptionalCreated parents need not to be immediate. Parents can be created at level up from the target element
Returns
NameTypeDescription
parent element$.ObjsAfter appending parent element, it is wrapped as Nedil Object and returned.
Example 1
Clicking on "Add Parent" button will add a parent div element to #child.
JS HTML CSS
		$.domLoaded(function() {

			$.get("#add").on("click", function() {
			
				//add a parent div to #child
				$.get("#child").addParent("div", {
					"class" : "parent",
					"text" : "Parent"
				});
				
			});
			
		});						
						
<body>

<div id="child"> Child </div>

<br/>

<input type="button" id="add" value="Add Parent" />

</body>
		.parent {
			display : inline-block;
			width : 100px;
			height : 100px;
			border : 2px solid red;
			padding : 10px;
		}
		
		#child {
			width : 50px;
			height : 30px;
			border : 2px solid blue;
		}
Result
Example 2
Adding a parent div to the #parent using #child DOM functionality. This can be applied any available level up in the DOM structure.
JS HTML CSS
		$.domLoaded(function() {

			$.get("#add").on("click", function() {
			
				//add a div parent to #parent using #child DOM
				$.get("#child").addParent("div", {
					"class" : "new",
					"text" : "New Parent"
				}, 1 );
				
			});
			
		});							
						
<body>

<div id="gparent">
Grand Parent
	<div id="parent">
		Parent
		<div id="child"> 
		Child
		</div>
	</div>
</div>

<br/>
<input type="button" id="add" value="Add Parent div to #parent using #child DOM functionality" />

</body>
		div {
			display : inline-block;
			margin : 5px;
			border : 2px solid red;
			padding : 10px;
		}
		
		#child, .new {
			border : 2px solid blue;
		}
Result