how to make the function parameter a String

0

Hi, I'm trying to generate a table but by making the function parameter text I've had a lot of problems this is the code:

 elemento = elemento +'</br>'+'<span onclick="borrar('+libros[i].autores[j]+');">'+libros[i].autores[j]+'</span>';

I generated it that way and it should be: "Jhon Stamos" as String in the parameter

help please

    
asked by Yept 19.11.2017 в 01:45
source

1 answer

0

The error is due to the concatenations, you must take into account when necessary the single quotes and the double quotes.

 elemento = elemento +'</br>'+"<span 
 onclick="+'"'+"borrar("+"'" +libros[i].autores[j]+"'" +")" 
 +'"'+">" +libros[i].autores[j]+'</span>';
    
answered by 19.11.2017 / 03:21
source