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')
} )
);
);
-> Please see my jsfiddle for examples (test case)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…