Sachin Prasad Sachin Prasad - 1 year ago 87
HTML Question

Replace an input value next to span element

I have to this input:

<input type="text" id="my_input" />

After a user enters anything in the input I have to append this next to the span.

<p id="patient_provider" >

The code I used is(It should be something like below):


But this is not working.

It is showing something like:

[object HTMLSpanElement] Sam

Also please note :

There are some css implemented on the span directly and I can not add another span

Answer Source

$('#patient_provider').children()[0] is an element and is converted to a [object HTMLSpanElement] string

The right is:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download