We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

FairyBusiness
on
Medium Priority
245 Views
Last Modified: 2012-05-11
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??
Comment
Watch Question

Commented:
$("#divId").html(varname);
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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

Author

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!!  ?????
Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
what does the e mean?
and why do you comment out the .innerHTML???

Author

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
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
e for event (click) : http://api.jquery.com/event.preventDefault/

innerHTML replace
append add
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
and I can't locate the div with the div ID "your_div_id"

Author

Commented:
the lowercase 's' and append worked!!!  :)   Thanks
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You're welcome! Thanks for the points!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.