mardi 20 janvier 2015

trying to alert random text instead of numbers

Doing a random generator that random the different options you put in, i've tried to make it alert the number of the option wich worked, but i want it to alert the text chosen instead of the number. below is my jQuery code



$(document).ready(function() {
$('#val').click(function() {
var toAdd = $("input[name=message]").val();
$('#messages').append("<p>"+toAdd+"</p>");
});
$('#kor').click(function() {
var random = Math.floor((Math.random()*$("#messages>p").length)+1);

alert(random);

});
});




Aucun commentaire:

Enregistrer un commentaire