Append input field value

I'm trying to append a value already in an input field, but the value just keeps going after the input tag? This is being done from inside a lightbox, I can change the value fine, but I need to be able to keep what was there to start with and add to it.

I've currently got this:

$("#gallpics", top.document).append("new pic");

Thanks,

Chris
djfenomAsked:
Who is Participating?
 
santhimurthydCommented:
Try with this
var exisval = ("#gallpics", top.document).val();
 ("#gallpics", top.document).text(exisval + "new pic");
0
 
leakim971PluritechnicianCommented:
to change a input value use : http://api.jquery.com/val/

The .val() method is primarily used to get the values of form elements such as input, select and textarea. In the case of <select multiple="multiple"> elements, the .val() method returns an array containing each selected option; if no option is selected, it returns null.
0
 
djfenomAuthor Commented:
Hi santhimurthyd,

That works, thanks!

Chris
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.