I have few fields and I want the values inside those fields to get copied to tbody td.
I have made an jsfiddle could someone please take a look at it.
I would like to have each tbody td looks like follow:
Copied value: (value that was typed inside the fields)
Any kind of help is appreciated
Thanks in advance!
Well here is a working version of your code. Now for the explanation.
Quick! What is wrong with this code.
It has two
ids which prevents us from selecting it byid. Secondly, in your code you are trying to set the value of a textbox (#1) to the value of atd(#S).So we need to change that code to.
Ah, but this code still won’t work. This is because a cell doesn’t have a value attribute, which is what
val()returns. Instead we are trying to set theinnerHTML; which has a jQuery alternative ofhtml().And, tada! It works! =D
EDIT: Getting the text of a selected option.
To do this we need to get the selected option. Which we can do via the
:selectedselector.Now we just get the inner text of this using the
text()method.Put it all together and we get.