Howto access input filed with id selector?

Howto access input filed with id selector?

hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

Hello,
I think it is a simple beginner question.
My datatable has a "Edit" button like in the example from here. If you click on "Edit" the column "salary" will be an input text with id =
"txt_salaryedit"

I tried to have access to this input with normal jQuery ID selector like below:

function editRow ( oTable, nRow )
{
$('#txt_salaryedit').on('input', function (event) {
alert('edit');
this.value = this.value.replace(/[^0-9]/g, '');
});
...

Nothing happens, no alert?
What doing wrong?

regards
Hans

Answers

  • hawkmasterhawkmaster Posts: 56Questions: 20Answers: 0

    Ahh, I just recognized my problem:
    the code;
    $('#txt_salaryedit').on('input', function (event) { alert('edit'); this.value = this.value.replace(/[^0-9]/g, ''); }); ...
    was at the wrong position. If I put it at the end of the edit row function then it works :-)

This discussion has been closed.