I have a div like this in my view, keep in mind this is inside of a @foreach loop in my razor view:
<div class="testClass">
<input type="text" class="tempLabel" />
<input type="button" data-value=@(item.ID) class="testButton3" value="Test Alert" />
</div>
This javascript works:
$(".testButton3").click(function () {
alert($(this).attr('data-value'));
});
what I want to do is get the value of the textbox inside of my tempClass class when I click the above button. I tried this but it does not work:
$(".testButton3").click(function () {
alert($(".tempLabel").($(this).val()));
});
Is this possible? Perhaps it is not possible to get the value of the textbox inside a foreach loop....