0
I need to take the generated name inside the id="pegname" and put inside the id="name", I did the code below, but it didn’t work.
The tag of the span id="pegname" generates the name of the client, in the case of Fulano da Silva and then with the script would return only the first name.
<span data-customer="name" id="pegarnome" ></span>
<span id="nome"></span>
<script>
var str = document.getElementById("pegarnome").innerHTML;
var res = str.split(" ",1);
document.getElementById("nome").innerHTML = res;
</script>
It worked in parts, generating name within span only appears after the script for what I noticed, ie it does not take any attribute. I tested by manually putting a name inside the span and it worked.
– Rafael Meirim