[jQuery] creating and inserting a new element fails in IE7

[jQuery] creating and inserting a new element fails in IE7


Hi!
The following function converts buttons dynamically to links (so I can
format the links with CSS later)
Works fine with FF3 and Opera.
But in IE7 the <a> element does not get inserted and I have no clue
why!?
In IE7 it seems to fail in line
var c = $
('<a>').insertAfter(this).addClass(this.className).attr('id',this.id
+'_r');
my javascript debugging capability in IE7 is limited but this <a>
element never shows up according to all my DOM inspections.
Any help from a professional is desperately needed.
Thank you!
Carsten
--- snip ----
// This script convert buttons to css-stylable "a href" links
//make sure your buttons have an ID and the class 'btn' - otherwise it
won't work
$(document).ready(function(){ // go!
$('.btn').each(function(){ // iterate over each class .btn element
var b = $(this);
var tt = b.text() || b.val();
if ($(':submit,:button',this)) {
var c = $
('<a>').insertAfter(this).addClass(this.className).attr('id',this.id
+'_r');
c.text('').css({cursor:'pointer'}).prepend('<i></i>').append($
('<span>').text(tt).append('<i></i><span></span>'));
var type = $(this).attr('type');
if(type == 'submit' || type == 'reset') {
$(this).hide();
}
else{
$(this).remove();
}
}
$('#'+this.id+'_r').click(
function()
{
$(this).parents('form').submit();
}
);
});
});