2
        $('#myTable').find('td').click(function() { 

            $('#meaningtextarea').val($("[type='hidden']", this).val());
            
        });

I need to convert this event to below format. could you please help me with this.

$(document).on('click', '#element', function (evt) {
    
});
0

1 Answer 1

1

Try this:

$(document).on('click', '#myTable td', function(e){
  console.log($(this).text())
})
table, tr, td {
  border : 1px solid black;
  }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Target table -->
<table id="myTable">
  <tr>
    <td>aa</td>
    <td>bb</td>
  </tr>
</table>
<p>

<!-- Test table -->
<table >
  <tr>
    <td>xx</td>
    <td>zz</td>
  </tr>
</table>

Sign up to request clarification or add additional context in comments.

1 Comment

$(document).on('click', '#myTable td', function(evt) { $('#meaningtextarea').val($("[type='hidden']", this).val()); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.