admin管理员组

文章数量:1026989

Using

$("#input_text").appendTo("#somediv")

Appends the text field itself, I want to append it's value entered by user not itself.

Or if there a way to just use something like ""+valueoffield+", bla bla".

How should I do this?

Thanks.

Using

$("#input_text").appendTo("#somediv")

Appends the text field itself, I want to append it's value entered by user not itself.

Or if there a way to just use something like ""+valueoffield+", bla bla".

How should I do this?

Thanks.

Share Improve this question asked Jul 17, 2013 at 22:19 Blessing ThinkerBlessing Thinker 2711 gold badge4 silver badges14 bronze badges 1
  • Append the value of a text field, not the text field itself. – Blessing Thinker Commented Jul 17, 2013 at 22:28
Add a ment  | 

3 Answers 3

Reset to default 5

If you need to append the value of your input to #somediv, what you need to do is:

$( "#somediv" ).append( $( "#input_text" ).val() );
$("#somediv").append($("#input_text").val());

If you would like to keep using appendTo. You have no option but to use it with some html tag when appending.

$('<span>' + $('#textbox').val() + '</span>').appendTo('#foo');

Try this :

<div id="append">

js:

var append_photo='<img src="{@user_image}" class="img-thumbnail" alt="Thumbnail Image"style="width:125px; height:125px">';

$("#append").append(append_photo.replace("{@user_image}","image/profile_thumb.jpg"));

Using

$("#input_text").appendTo("#somediv")

Appends the text field itself, I want to append it's value entered by user not itself.

Or if there a way to just use something like ""+valueoffield+", bla bla".

How should I do this?

Thanks.

Using

$("#input_text").appendTo("#somediv")

Appends the text field itself, I want to append it's value entered by user not itself.

Or if there a way to just use something like ""+valueoffield+", bla bla".

How should I do this?

Thanks.

Share Improve this question asked Jul 17, 2013 at 22:19 Blessing ThinkerBlessing Thinker 2711 gold badge4 silver badges14 bronze badges 1
  • Append the value of a text field, not the text field itself. – Blessing Thinker Commented Jul 17, 2013 at 22:28
Add a ment  | 

3 Answers 3

Reset to default 5

If you need to append the value of your input to #somediv, what you need to do is:

$( "#somediv" ).append( $( "#input_text" ).val() );
$("#somediv").append($("#input_text").val());

If you would like to keep using appendTo. You have no option but to use it with some html tag when appending.

$('<span>' + $('#textbox').val() + '</span>').appendTo('#foo');

Try this :

<div id="append">

js:

var append_photo='<img src="{@user_image}" class="img-thumbnail" alt="Thumbnail Image"style="width:125px; height:125px">';

$("#append").append(append_photo.replace("{@user_image}","image/profile_thumb.jpg"));

本文标签: JavaScriptJQueryhow append field value to idStack Overflow