How to pass a td text to echo it somewhere else (jQuery) -
i got loop puts multiple tables on screen same class, same markup other content, depends on outcome of query.
so example output be
<table class='tablestyleorchideevraag'> <tr><td>hi</td></tr> </table> <table class='tablestyleorchideevraag'> <tr><td>bye</td></tr> </table> how can pass td text .onclick() , how can text echo later on screen after clicking?
so, when click table class='tablestyleorchideevraag' needs store td text somewhere. when click table td text hi, needs save text hi. when click table td text bye, needs save text bye.
when clicked want echo stored text
$(document).ready(function(){ var lastclickedvalue = ""; $('.tablestyleorchideevraag').on('click', function(){ var value = $(this).find('tr:first td:first').html(); lastclickedvalue = value; console.log( value ); }); $('someotherselector').on('click', function(){ console.log( 'the last value clicked was: '+ lastclickedvalue ); }); });
Comments
Post a Comment