All the above solutions are useful. And they used the line lol = document.getElementById('lolz').value;
inside the function function kk()
.
What I suggest is, you may call that variable from another function fun_inside()
function fun_inside()
{
lol = document.getElementById('lolz').value;
}
function kk(){
fun_inside();
alert(lol);
}
It can be useful when you built complex projects.