I have unordered list of links and i am trying to get the clicked link text. So when i click on some link i would like to display in paragraph or textbox at the bottom of my list text that is cliked. So if I have something like this:
- item1
- item2
- item3
If i click on item2 i would like to get it like: "You just clicked:item2 "
And i manage that with this:
jQuery(function () {
$('a').click(function () {
alert('Text is: ' + $(this).text());
});
});
But that is displaying an alert message. then i do this:
jQuery(function () {
$('a').click(function () {
var name = $(this).text();
$("p#selector").text(name);
$("input#textbox").val(name);
});
});
And it works it send text value of a link to paragraph but it disappear really fast, it show it about second and it's gone, is there any way to prevent this? To stop it from disappearing?