Ich versuche, eine Inline-Bearbeitung von Todo-Listen zu implementieren. Ich habe diesen Code und ich möchte in der Lage sein, den Wert darin zu bekommen.Wie bekomme ich Wert innerhalb .html() in JQuery
$(function clickedit() {
$(".a").dblclick(function (e) {
e.stopPropagation();
var currentEle = $(this);
var value = $(this).html();
var id_val = $(this).attr('value');
//alert(id_val);
updateVal(currentEle, value, id_val);/**/
});
});
function updateVal(currentEle, value, id_val) {
$(currentEle).html('<input class="thVal" id="aaa" type="text" value="' + value + '" />'); // i want to get the value inside the input
var aaa = $('#aaa').val();
$(".thVal").focus();
$(".thVal").keyup(function (event) {
if (event.keyCode == 13) {
alert(aaa);
$.post('includes/edit-task3.php', { task_name: aaa, task_id: id_val}, function() {
$(currentEle).html($(".thVal").val().trim());
alert('in');
//current_element.parent().fadeOut("fast", function() { $(this).remove(); });
});
}
});
$(document).click(function() {
$(currentEle).html($(".thVal").val().trim());
});
}
Wie kann ich den aktuellen Wert in der Eingabe innerhalb .html() erhalten?
Ich versuchte, var aaa = $('#aaa').val();
, aber es funktioniert nicht .. Wie kann ich das tun?
Vielen Dank für Ihre Hilfe.
'$ (currentEle) .find ('# aaa'). Val (); 'versuchen Sie diese – guradio
Sie diese gehackte Version' var aaa = value'; – madalinivascu
@ madalinivascu, Oder einfach "Wert" verwenden: P – Rayon