What I'm trying to do is when you click on a button, an alert comes up with a prompt for the user to input their name in. Once the user enters their name, I want their name to appear in a h2 (class= "pName"). I can't seem to get this to work, am I coding this wrong?
Javascript
$("#newPlayer").click(function(){
var newPlayer = prompt("Please enter your name.","");
if(newPlayer != null){
document.getElementsByClassName("pName").innerHTML = newPlayer;
}
});