aşağıdakilere sahip HTML:
(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);
Sen
$("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"/>
ile çağırmalıdır:
<input type="text" class="myclasses" style="color: #123123" value="akira"/>
sonra aşağıdaki parçacığını kullanarak 210 "
" Metin kutusu "terimi yeterince açık değildir. Bu ASP.NET'e özgü gibi görünüyor. jQuery bunu anlamıyor. Sadece HTML'yi anlar. HTML ' veya belki"
@BalusC Bunu bir "giriş tipi = metin" yi bir "textarea" haline dönüştürmek olarak yorumluyorum. Bence bu sadece girdiyi yok ederek ve aynı isimde bir textarea oluşturarak yapılabilir. –
@Pekka: Doğru, ama bu terimdeki belirsizlik var ve ben bunu OP'nin pozisyonuna dayanarak değerlendirdim. Zaten bir çeşit MVC framework tarafından üretilen bir "tek satır" kısıtlaması ile bir "