문제

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