I have the following script:
function add_fields(link, association, content) {
var new_id = new Date().getTime();
var regexp = new RegExp("new_" + association, "g");
$(link).parent().before(content.replace(regexp, new_id)).show("slow");
}
I’ve added .show("slow") so that the new field will be shown slowly, but it ain’t working. I have tried moving it around the same line, but nothing works.
Where have I gone wrong in this? Thanks.
.before() returns $(link).parent(), not the inserted element.
Depending if content contains a HTML string with exactly one top level element, this might do: