How do I rewrite .after( content, content )?
- by Evan Carroll
I've got this form working, but according to my previous question it might not be supported: it isn't in the docs either way -- but the intention is pretty obvious in the code.
$(".section.warranty .warranty_checks :last").after(
$('<div class="little check" />').click( function () {
alert('hi')
} )
, $('<span>OEM</span>') /*Notice this (a second) argument */
);
What this does is insert <div class="little check"> with a simple .click() callback, followed by a sibling of <span>OEM</span>. How else can I write this then? I'm having difficulty conjuring something working by chaining any combination of .after(), and .insertAfter()?
I would expect this to work, but it doesn't:
$(".section.warranty .warranty_checks :last").after(
$('<div class="little check" />').click( function () {
alert('hi')
} ).after ( $('<span>OEM</span>') )
);
I would also expect this to work, but it doesn't:
$(".section.warranty .warranty_checks :last").after(
$('<span>OEM</span>').insertAfter(
$('<div class="little check" />').click( function () {
alert('hi')
} )
);
);