最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Jquery , how append field value to id - Stack Overflow

matteradmin5PV0评论

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"));

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far