1
I have a problem I don’t know why... I have a table in which one of the columns gets the input and when onkeyup in this input, I need to get the innerHTML from the column next:
<script type="text/javascript">
$('#pedido').on('keyup', '.qte', function () {
var x = $(this).closest('#custo').innerHTML;
console.log(x)
});
</script>
He is not finding the #cost, back to Undefined message.
I wonder what I’m doing wrong?
If
#custo
is an id, so it’s unique on the page, so don’t just do$("#custo")
?– Woss
Anderson, he’s not the only one. He may have more than one line. It’s an order table.
– Jeferson Costa
So your HTML structure is wrong. Why it is considered wrong/bad to repeat an HTML ID?
– Woss
You’re correct, I should use the class then. But it still doesn’t work...
– Jeferson Costa
Then edit the question and add a [mcve] that reproduces the problem
– Woss
Thank you so much for your time... If you couldn’t understand my problem, it’s not you who will help me.
– Jeferson Costa
Jeferson, I recommend you do the [tour], read the [Ask] guide and go to [help] for more information about the operation of the site. This will help you greatly in future interactions. It’s not a question of understanding the problem, it’s clear, there’s just no way to replicate it to suggest the solution. See that even in the answer in Virgilio Novic right at the end he says exactly that. The only thing in this situation is to show a way to do it, at the risk of not being valid for you and even if it works you will not understand why yours didn’t work. I see no advantage to anyone in this.
– Woss