Вопрос

I have this html code working on GreaseMonkey extension for webbrowsers:

document.body.innerHTML=document.body.innerHTML.replace("value=\"9,00\"","value=\"4,00\"");

But what really I want is to match the full line:

<td><input name='nota3'  size='5' READONLY value="9,00" >

I've tried to escape the single quotes like the doublequotes in the first example but is not working:

document.body.innerHTML=document.body.innerHTML.replace("<td><input name=\'nota3\'  size=\'5\' READONLY value=\"9,00\" >","<td><input name=\'nota3\'  size=\'5\' READONLY value=\"4,00\" >");

How I can do it?

Это было полезно?

Решение

Try this:

document.body.innerHTML=document.body.innerHTML.replace("<td><input name='nota3'  size='5' READONLY value=\"9,00\" >","<td><input name='nota3'  size='5' READONLY value=\"4,00\" >");

You don't need to escape the single quotes, because they're enclosed in double quotes, and therefore do not interfere with closing the double quotes.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top