Jesse McMillan Jesse McMillan - 16 days ago 4
Javascript Question

jquery how do I find value of input within table?

I'm an absolute novice at jquery.

Currently I have a table row:

<tr id="someID">
<td class="pin"><input type="text">/td>
<td><button class="addpin" type="button">ADD</button></td>

I'm having a hard time getting the value of the text input. Here's what I have:

$(document).on('click', ".addpin", function() {
var mypin = $(this).parent().siblings(".pin").html();

which alerts:

<input type="text">

but when I try:

$(document).on('click', ".addpin", function() {
var mypin = $(this).parent().siblings(".pin").val();

it's blank no matter what's in the input. What am I doing wrong?

var mypin = $(this).parent().siblings(".pin").children(0).val();

This will need to be adjusted if you put anything else into this cell.