denhamd2
01-20-2011, 05:46 PM
Hi,
I'm looking to change some DOM elements - <a> tags to <input> tags whilst keeping the attributes of the element. Here is the Jquery function I'm using:
// Function to replace buy buttons with radio buttons
jQuery.fn.replaceWith = function(replacement) {
return this.each(function(){
element = $(this);
$(this)
.after(replacement).next()
.attr('value', element.attr('href'))
.html(element.html())
.prev().remove();
});
};
and here is the implementation:
$('div.yearDiv a').replaceWith('<input type="radio" name="prod" />');
This works fine in Firefox and Chrome, but doesn't work at all in IE and causes a Javascript error. If you have any ideas I would be very grateful.
I'm looking to change some DOM elements - <a> tags to <input> tags whilst keeping the attributes of the element. Here is the Jquery function I'm using:
// Function to replace buy buttons with radio buttons
jQuery.fn.replaceWith = function(replacement) {
return this.each(function(){
element = $(this);
$(this)
.after(replacement).next()
.attr('value', element.attr('href'))
.html(element.html())
.prev().remove();
});
};
and here is the implementation:
$('div.yearDiv a').replaceWith('<input type="radio" name="prod" />');
This works fine in Firefox and Chrome, but doesn't work at all in IE and causes a Javascript error. If you have any ideas I would be very grateful.