JQuery object object output

this is my table button with value

'<tr>
   <td>' + valueAusData.Spieler_Name + '</td>
   <td>' +  valueAusData.Note + '</td>
   <td>' + valueAusData.Tore +'</td>
   <td> <button class="edit-modal btn btn-info" id="inputSpieler" value="valueAusData.Tore">' + "Edit" + '</button>
</tr>';

and here is my java script function

 $( '#myTable' ).on( 'click', 'button', function(g) {
        alert(g);
 });

But I get back object object and not the value of valueAusData?

Okay I have the solution

alert($(this).val());

But how can I store more the 1 field in the button value part? I need value="valueAusData.Tore" and value="valueAusData.Note" and then I want to alert them.

2 answers

  • answered 2017-08-12 09:47 Hamza Abdaoui

    From the documentation, function(g) is :

    handler Type: Function( Event eventObject [, Anything extraParameter ] [, ... ] )

    So g is an Event which is an Object.

    I think that you are trying to display a modal, so add this line instead of alert(g); :

    $("#myModalId").modal('show');
    

  • answered 2017-08-12 09:47 MrViK

    If ausData is type object, when you try to convert it to a string, result will be Object object. If you expect to get the entire object as a string use JSON.stringify(data)