prototypejs - Prototype.js: Showing the next hidden div -


how show hidden adjacent div on prototype.js? here current code:

<button id="checkanswer" onclick="checkanswer2()">check answer</button> <p class="feedback">feedback:</p> 

script:

function checkanswer2 () {     $('checkanswer').next().show();         } 

if put id in function, you’re going have make new function each question/answer pair. how this:

<button class=“checkanswer”>check answer</button> <p class=“feedback”>feedback:</p> 

script

$$('.feedback').invoke('hide'); $(document).on('click', '.checkanswer', function(evt, elm){   elm.next('p').show(); }); 

now can repeat many of these want on page, , each button manage whatever p follows it.