Test case for jQuery Ticket 7795
append string
by jitter
HTML
<p>
<button id="click"> Click me </button><br />
red = div<br />
green = p<br />
blue = form
</p>
<p><br />append checked radio to div and p</p>
<div id="d1"></div>
<p id="p1"></p>
<p><br />append checked radio to form</p>
<form action="." id="f1"></form>
<p><br />append checked radio to div/p which are inside a form</p>
<form action=".">
<div id="d2"></div>
<p id="p2"></p>
</form>
CSS
div, #p1, #p2, #f1 { border: 3px solid; margin: 3px; padding: 2px; }
div { border-color: red }
#p1, #p2 { border-color: green }
#f1 { border-color: blue }
JavaScript
//different strings so they are cached separately
var strs = [
'<input id="i1" type="radio" name="i1" value="1" checked="checked" />',
'<input id="i2" type="radio" name="i2" value="1" checked="checked" />',
'<input id="i3" type="radio" name="i3" value="1" checked="checked" />',
'<input id="i4" type="radio" name="i4" value="1" checked="checked" />',
'<input id="i5" type="radio" name="i5" value="1" checked="checked" />',
],
$e = $("#d1, #p1,#f1, #d2, #p2");
//although the support check returns true in Safari 5 and Chrome
//it still fails to cloneNode fragments which contain checked
alert( jQuery.support.checkClone );
$("#click").click(function() {
$e.each(function( i, ele ) {
$(ele).empty().append( strs[i] );
});
});