Manipulate

Using these methods, you can change the contents and order of the DOM tree.

html( )

Returns the innerHTML of the first element in Karmagination.

<div id="one">Hi</div>
alert(Karma('#one').html()); // Hi

html( val )

Sets the innerHTML of the elements to val.

<div>a</div>
<div>b</div>
Karma('div').html('hi');
alert(Karma('div').eq(0).html()); // hi

text( )

Returns the innerText of the first element.

<div>a <b>b</b></div>
Karma('div').text(); // returns 'a b'

text( val )

Change the innerText of the elements.

Karma('div').text('hello');
Karma('div').text(); // returns 'hello'

append( content )

Appends content (element/elements/html) to current set of elements

appendTo( selector )

Appends current set of elements to the elements that are matched by the selector (element/elements/html)

prepend( content )

Prepends content (element/elements/html) to current set of elements

prependTo( selector )

Prepends current set of elements to the elements that are matched by the selector

after( content )

Inserts the elements that matches the selector after current elements.

before( content )

Inserts the elements that matches the selector before current elements.

insertAfter( selector )

Inserts current elements after the elements that matches the selector (element/elements/html).

insertBefore( selector )

Inserts current elements before the elements that matches the selector (element/elements/html).

wrap( html )

Wrap the current elements with the html. Note: Karmagination only supports unnested html, ie: <div></div> but not <div><span></span></div>

empty( )

Removes all the descendants of the current elements.

remove( [selector] )

Removes current elements that matches the selector from the document.

clone( )

Make clones of the current elements. Event cloning is not supported yet.