View Full Version : Problem with changing DOM element in IE

01-20-2011, 05:46 PM

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);



.attr('value', element.attr('href'))





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.