私はhtmlを持っています
<div id=1>
<span id=2></span>
</div>
<div id=3>
</div>
アンカーを置き換えspanて使用しようとしていますa.toggle() <div id=3>
$('#2').replaceWith(function(){
return $("<a id=\"2\" href=\"#\" />").append($(this).contents());
});
これは、スパンをアンカーに変えるときに機能しますが、クリック機能をチェーンしようとすると.toggle()、トグルが拒否されます。
$('#2').replaceWith(function() {
return $("<a id=\"2\" href=\"#\" />").append($(this).contents());
}).click(function() {
$('#3').toggle();
return false;
});
.toggle()を外すとクリック機能が働きます.replaceWith()。