jquery - How to receive the current html code with html() after changed input value? -


ok demonstrate mean created little jsfiddle: http://jsfiddle.net/b2fzb/

it pretty useless function. if type "a" first input field html source code of wrapper div displayed. it's still old value. need know is: how html source code new value?

is there way html() or special event listener it?

here code:

js:

$(document).ready(function () {     console.log('ready');     $('.input1').keyup(function () {         console.log('changed');             if ($('.input1').val() == "a") {                 var source = $('#input_wrapper').html();                 alert(source);             }     }); }); 

html:

<div id="input_wrapper">    <input type="text" value="abc" class="input1">    <input type="text" value="def"> </div> <div id="get_html_code">get html source code</div> 

reason used value attribution,it not change typed text value, try change according user entered input

$('.input1').keyup(function () {         console.log('changed');                             if ($('.input1').val() == "a") {              $(this).attr('value',$(this).val()) // line change value             var source = $('#input_wrapper').html();             alert(source);         }                     }); 

demo


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -