Pergunta

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!

Foi útil?

Solução

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

fiddle

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top