I want to get the id
from the parent element of a button, and the cut the text of. My guess was this:
HTML
<div id="test_4">
<button id="button">Get ID</button>
</div>
JavaScript
$('#button').click(function() {
parentID = $(this).parent().attr('id');
newID = parseInt(parentID);
alert(newID);
});
But that outputs NaN
.
What is the right way to do this? fiddle