I'm trying to place headers around a couple of anchors with Prototype. But it doesn't work? Can someone help me with this? Thanks.
function placeheader(item, i)
{
item.insert({
//This doesnt work:
before: "<h3>",
after: "</h3>"
//This works:
//top: "test3",
//bottom: "test4"
});
}
$$('div.subresult a').each(placeheader);
I'm afraid you cannot use the insert() method with partial tags, try this:
function placeheader(item) {
var header = $(document.createElement("h3"));
item.up().insertBefore(header, item);
item.remove();
header.appendChild(item);
}
$$("div.subresult a").each(placeheader);