I have a view, which dynamically creates several elements of type Button
in the following way:
@foreach (PacienteSeleccionDispensarDto paciente in @Model)
{
<input type="button" name="btnPaciente" id="[email protected]"
value="@paciente.NombrePaciente" onclick="fnProcesaPaciente()" />
}
in the event onclick
, I put the function fnProcesaPaciente
, in which I need to rescue the id of the button that the user pressed, and was trying in the following way
var PacienteId = $(this.data("id"));
but apparently this does not work, because the buttons are created in a partial view, not in the main view (I do not know if this will have an impact).
How can I know the ID of the button pressed?
Greetings