Using jquery 1.7.1
I know there is native javascript swapNode method.....
is there swapNode in jQuery. Which will be more cross browser compatible...
Ed: adding below code.
- $("._parent").children().on("click", function (event) {
- var _emptyClone = $("._empty").clone();
- $("._empty").replaceWith($(this).clone());
- $(this).replaceWith(_emptyClone);
- });
<div class="_parent">
<div class="_child">child 1</div>
<div class="_child">child 2</div>
<div class="_child">child 3</div>
<div class="_empty">empty</div>
</div>
intention is to retain event listener....
tried..
$("._empty").replaceWith($(this).clone()).on("click", function (event) {
alert("new listener")
});
I tried live
- $("._parent").children().live("click", function (event) {
- var _emptyClone = $("._empty").clone();
- $("._empty").replaceWith($(this).clone())
- $(this).replaceWith(_emptyClone);
- });
- Uncaught Error: Syntax error,
- unrecognized expression: )