Pregunta

I need to add a line break immediately prior to every instance of a parenthesis using JavaScript (specifically jQuery).

I've been unable to locate any documentation that indicates I can search a string, by specifying it's class/ID, for a special character (in this case the parenthesis) and prepend HTML to it.

Can anyone assist me? Thank you!

¿Fue útil?

Solución

$("#unique").html( function(i, oldtext){
    return oldtext.replace("(","<br> (");
});

fiddle

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top