I want to get the text of individual selectors, in my case, only the first selector is always displayed: <div id="nick">Текст1</div> , and it is necessary that if I clicked on the third: <div id="nick">Текст3</div> , then brought the text: Text3
The code is:
<!DOCTYPE html> <div id="nick">Текст1</div><br><br> <div id="nick">Текст2</div><br><br> <div id="nick">Текст3</div><br><br> <div id="nick">Текст4</div><br><br> <div id="nick">Текст5</div> <script> jQuery('div#nick').on('click',function(){jQuery('div#nick').text().index()}){ console.log(); } </script> </body>