I have a function where input element triggers ng-blur method with $event parameter:
$scope.MarkField = function(event)
{
}
<tr>
<td><input type="text" value="1" id="inputQuantity" ng-blur="MarkField($event);"></td>
<td><input type="text" value="1" id="inputBruto"></td>
<td><input type="text" value="1" id="inputNeto"></td>
</tr>
What I need to do is find values of other two inputs (inputBruto and inputNeto) in this row when ng-blur is clicked. How to do this?
EDIT:
I am passing $event parameter because I know I can do something like this:
$(event.target).parent().parent() - the row where all three inputs are.
But I don't know how to use this row later to get input by id.
It would be nice if something like this is possible:
$("#rowID > td > input[id=inputBruto]");
EDIT:
I've managed to find / change input[id=inputBruto] with:
$(event.currentTarget).parent().parent().find("input[id=inputBruto]").val("test")
Problem solved, thanks for help!
You can try this,
$scope.MarkField = function($event)
{
/* to get tr element */
var parent = $event.currentTarget.parent().parent()
var idCurrent = $event.target.id;
/*from parent finding for #inputBruto & #inputNeto */
var secInput=parent.querySelector("#inputBruto").value;
var thirdInput=parent.querySelector("#inputNeto").value;
}
Try this, find parent of the clicked element and find in that your id elements
$scope.MarkField = function($event)
{
var parent=$event.target.parent();
var secInput=parent.find("#inputBruto").val();
var thirdInput=parent.find("#inputNeto").val();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With