You’re taking all the content because when you put it $('.insert').text()
you take the text of all elements with class . Insert.
It works if you do a click event:
$(".insert").click(function(){
var conteudo = $(this).text();
});
This way it takes the text from the place where you clicked.
To do the click function is this same way, and works normal within $(Document).ready. The syntax is
$("seletor").click(function(){
// o que acontece ao clicar
});
As you may have noticed with the first example I gave, hehe. If you will use this within the function insertDado()
, you have to perform this function after you set, just by writing insertDado()
within the $(document).ready
.
I hope you’re not too confused.
The purpose of using jquery is to eliminate that lot of javascript online in html, and have the flexibility of selectors as in CSS, prefer to do everything with jquery as in this fiddle.
– Jader A. Wagner