I'm converting an input field to reqular text with this snippet.
$(".supernappula").live('click', function() {
$('.item-quantity .simpleCart_input').replaceWith(function(){
return '<span class='+this.className+'>'+this.value+'</span>'
})
});
However, if the value has already been changed from input to span, it will convert it to undefined
and it shouldn't do it.
I was thinking a solution like this:
$(".supernappula").live('click', function() {
var howmany = $('.item-quantity .simpleCart_input').html();
if(howmany == "undefined"){return false;}
$('.item-quantity .simpleCart_input').replaceWith(function(){
return '<span class='+this.className+'>'+this.value+'</span>'
});
});
But it doesn't actually do anything. So basically, how would I stop it from executing if it's already converted?