Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery to bind input value to span or div?

Tags:

jquery

Please excuse me if this is a newbie question. I am new to this.

I would like that a user fill out a form with their info and, just before clicking submit, there to be a summary of details area where they confirm their details are correctly entered.

So is it possible for me to "bind" specific inputs to specific spans or divs and as they type (or maybe onBlur?) the span would reflect what is written in the respective input???

like image 613
Stefan Avatar asked Feb 11 '11 15:02

Stefan


2 Answers

Populate div with id somediv with whatever is typed the input with id inputid each time a key is pressed:

$('#inputid').keyup(function() {
    $('#somediv').html($(this).val());
});
like image 149
Dan Grossman Avatar answered Sep 28 '22 17:09

Dan Grossman


$('#myFormField').bind('change', function(){
 $('#myTargetSpan').text($(this).val());
});
like image 43
Joe Green Avatar answered Sep 28 '22 19:09

Joe Green