Как использовать функцию множественного переименования с помощью javascript.
I'm new to Javascript and I've only recently learned HTML and CSS. So, example, in this example; <body> <p>Player 1: Chris</p> <script> var para = document.querySelector('p'); para.addEventListener('click', updateName); function updateName() { var name = prompt('Enter a new name'); para.textContent = 'Player 1: ' + name; } </script> The given Javascript can only change "Player 1: Chris". If I have to add "Player 2: Adam" the same script doesn't work. What modifications do I have to use?
Что я уже пробовал:
<body> <p>Player 1: Chris</p> <script> var para = document.querySelector('p'); para.addEventListener('click', updateName); function updateName() { var name = prompt('Enter a new name'); para.textContent = 'Player 1: ' + name; } </script>