tags:

views:

237

answers:

2

Rather than population said DOM object with an external page such as HTML CFM or PHP, what if I simply want to send text?

I've tried:

$("#myDOMObject").val("some text");

No errors, but the object value doesn't update either.

+4  A: 

What element is "myDOMObject"? If it's a text input, your code should be working fine. If it's something else, use $("#myDOMObject").text("some text");

John Millikin
the element is a Div with id of myDOMObject, not truly, but for examples sake. Anyway, I tried your format to no avail. I can make it a text input I suppose, with no background/border. I'm using it simply for a visual clue for the user. That their event is complete.
Gene R
Gene R: Are you sure that using .text() did not work? Did any errors appear in your console?
John Millikin
@Gene R, John's example is right other than the space between 'text' and the '('
Chris Sutton
Chris: eh, that's just stylistic, but I'll change it if it's a bother.
John Millikin
No, you were right, I missed a quote... using .txt on the div did itThanks a ton
Gene R
@Gene, I forgot js is that loose with the spacing and all.
Chris Sutton
+1  A: 

If you have a DOM object, you can simply do this:

jQuery(your_dom_object).text('Hello World!');

But, since you use jQuery anyway, I think you should just do

$('#the_id_of_your_dom_object').text('Hello World');

You can use any jQuery query instead of referencing the ID of the object directly. See the jQuery documentation for more details.

DrJokepu