javascript - Trouble with changing the text of an element based off of a text form .val() -
my app dynamically creates , deleted new elements based on + / - buttons. inside dynamically created elements text forms. want whatever user types text form displayed in dynamically created element.
$('.lname').keyup(function(event) { var crazy = {}; for (var x = 1; x < i; x++) { crazy[x] = function() { $('#sidechange'+ x).keyup(function(event) { var value = $(this).val(); $('.sloan'+ x).text(value); }) } } for (var p = 1; p < i; p++) { crazy[p](); } });
for example, accomplished changing text in previous element including function in html onkeyup attribute, don't know how accurately target other elements.
var changetitle = function() { var loantitle = $(this).val(); var code = $("input[type='text'][name='loanname']").keycode || $("input[type='text'][name='loanname']").which; var length = loantitle.length; console.log(length); if(length < 1 || code == 8) { $(this).prev().text('loan'); } else { $(this).prev().text(loantitle); } };
what youll want data bind 2 elements sort of id generate. in fiddle below, use incrementing number. when keyup happens, grab elements data-id , use find "mirrored" input.
$('.mirror[data-id="'+id+'"]').val(text);
your question bit vague think asking for.
Comments
Post a Comment