que han Considerando código HTML siguiente:
<input type="text" class="myclasses" style="color: #123123" value="akira"/>
a continuación, utilizando siguiente fragmento:
(function($) {
$.fn.changeToTextArea = function(rows, columns) {
var attrs = {};
var text = "";
$.each(this[0].attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
if(attr.nodeName == "value") {
text = attr.nodeValue;
}
attrs["rows"] = rows;
attrs["cols"] = columns;
});
this.replaceWith(function() {
return $("<textarea/>", attrs).append($(this).contents()).html(text);
});
}
})(jQuery);
usted debe llamar con
$("input").changeToTextArea(7, 25);
(function($) {
$.fn.changeToTextArea = function(rows, columns) {
var attrs = {};
var text = "";
$.each(this[0].attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
if(attr.nodeName == "value") {
text = attr.nodeValue;
}
attrs["rows"] = rows;
attrs["cols"] = columns;
});
this.replaceWith(function() {
return $("<textarea/>", attrs).append($(this).contents()).html(text);
});
}
})(jQuery);
$("input").changeToTextArea(7, 25);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<input type="text" class="xyzxterms" style="color: #123131" value="akira"/>
El término "cuadro de texto" no es lo suficientemente específico. Esto parece ser específico de ASP.NET. jQuery no entiende eso. Solo entiende HTML. ¿No te refieres a HTML '' o quizás a '
@BalusC Lo interpretaría como convertir un 'input type = text' en un' textarea'. Creo que solo se puede hacer destruyendo la entrada y creando un área de texto con el mismo nombre. –
@Pekka: cierto, pero hay ambigüedad en el término y juzgué eso basado en la historia de la OP. Puede suceder que ya tenga un '