javascript - Can't change value of div with jQuery -
i have problem in jquery: wrote code:
<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#input").keyup(function() { var input = $("#input").val(); var input = input.replace("d", "f"); $("#text").val(input); }); }); </script> </head> <body> <center> <input type="text" id="input" /> <div id="text"></div> </center> </body> </html> this code's suppose check if there d's in the variable "input" (which received input box in body) , replace d's f's (this little experiment before seek replace letters of 1 language letters of another). doesn't work , don't know why. tried replace $("#text").val(input); alert(input); , worked replaces first "d" "f" , sec , 3rd d's aren't replaced , remain "d". please help me. give thanks you.
you need html() or text() div instead of val()
$("#text").html(input); javascript jquery html
No comments:
Post a Comment