Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
85
rated 0 times [  90] [ 5]  / answers: 1 / hits: 21083  / 12 Years ago, sun, september 9, 2012, 12:00:00

I need to convert <input type=text value=1 class=simpleCart_input> to plain text.



Like I need it to be something like



<span class=simpleCart_input>1</span>


But how?


More From » jquery

 Answers
37

You can use replaceWith.



$('.simpleCart_input').replaceWith(function(){
return '<span class='+this.className+'>'+this.value+'</span>'
})


http://jsfiddle.net/fsVRe/



or:



$('.simpleCart_input').replaceWith(function(){
return $('<span/>', {
'class': this.className,
text: this.value
})
})

[#83171] Friday, September 7, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaylanw

Total Points: 730
Total Questions: 98
Total Answers: 95

Location: Saudi Arabia
Member since Tue, Nov 29, 2022
2 Years ago
;