I have these line of JavaScript:
I would like for it to return:
Your Name Is:
Cool Hand Luke
I want the "Cool Hand Luke" to be on a separate line but I don't know how to put a linebreak in the .text string. Is this something somebody could tell me how to do?
Code:
$(document).ready(function () {
/*$('#first').focus();
$(this).keyup(function (e) {
if (e.keyCode == 13) {
generate();
}
});*/
});
function generate() {
if($("input[name='name']").val().length > 1) {
fi = $("input[name='name']").val().substring(0,1).toUpperCase();
var sl = ["Cool "];
var sl2 = ["Hand "];
var sl3 = ["Luke",];
{
var i = Math.floor(Math.random() * sl.length);
var j = Math.floor(Math.random() * sl2.length);
var k = Math.floor(Math.random() * sl3.length);
var nick = sl[i] + sl2[j] + sl3[k];
}
{
$("#answer").text("Your Name Is: " +nick);
$("#answer").fadeIn("slow");
}
}
}
I would like for it to return:
Your Name Is:
Cool Hand Luke
I want the "Cool Hand Luke" to be on a separate line but I don't know how to put a linebreak in the .text string. Is this something somebody could tell me how to do?
Comment