Great answer! I had to change parent() to parents() to get it working. Here is the code:
$(document).ready(function(){
$("#myButton").click(function () {
val1 = $("td input[name='sub']:checked").parents().find('.desc').html();
val2 = $("td input[name='sub']:checked").parents().find('.price').html();
if (val1 == null){
alert("Please select one value above");
} else {
alert(val1 + " sells for " + val2);
};
});
});
Select | Product | Description | Price |
ABCDE | Product ABCDE | 55.95 | |
GHIFK | Product GHIFK | 34.99 |