What is jquery's equivelant to echo in php??

Hi, I grabbed  a value from a form and put it into a var:

$('#submit').click(function() {
      var name = new String($('form: #name').val());
});

I want to display this value in a div on my page. . . but I cannot figure how to do that.  I tried document.write a few times, but either that does not work with jquery or I am doing it wrong.  Anyone know how to display variables in jquery??
FairyBusinessAsked:
Who is Participating?
 
leakim971PluritechnicianCommented:
Use :
$('#Submit').click(function(e) {
      e.preventDefault();
      var name = $('#name').val();
      //$("#your_div_id").innerHTML(name);
      $("#your_div_id").append(name);
});

Open in new window

0
 
cmalakarCommented:
$("#divId").html(varname);
0
 
leakim971PluritechnicianCommented:
This is append :

you div like this :

<div id="your_div_id"></div>

So :


$('#submit').click(function() {
      var name = $('#name').val();
      //$("#your_div_id").innerHTML(name);
      $("#your_div_id").append(name);
});

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
FairyBusinessAuthor Commented:
The only two that worked slighty were:

$('#submit').click(function() {
      var name = $('#name').val();
      $("#name1").html(name);
});

and

$('#submit').click(function() {
      var name = $('#name').val();
      $("#name1").append(name);
});

Ok, but its having a strange affect.  It shows on the page while its loading but then once its done loading or transmitting data its gone!  Its like it flashes on the page for 2 seconds, then nothing!!  ?????
0
 
FairyBusinessAuthor Commented:
what does the e mean?
and why do you comment out the .innerHTML???
0
 
FairyBusinessAuthor Commented:
Its not showing at all now:

http://auroriella.com/story.html

I am only testing the first value.  When you click Tell Story should show the name Tanya under hello
0
 
leakim971PluritechnicianCommented:
e for event (click) : http://api.jquery.com/event.preventDefault/

innerHTML replace
append add
0
 
leakim971PluritechnicianCommented:
line 1 rename replace "S" by "s"

or rename your button "Submit" instead "submit"
0
 
leakim971PluritechnicianCommented:
and I can't locate the div with the div ID "your_div_id"
0
 
FairyBusinessAuthor Commented:
the lowercase 's' and append worked!!!  :)   Thanks
0
 
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.