如何替换 noscript (wordpress) 中的值?

How to replace value in noscript (wordpress)?

我需要替换 noscript 中的值。
我尝试了以下代码,但它没有替换值。
你能告诉我如何修复代码吗?

我试过了:

jQuery("ls-slot-shortcode_actions a noscript").replaceWith("width=42");

现有代码:

<li class="ls-slot-shortcode_actions">
     <a href="https://www.myhome.com">
          <img scr="https://www.myhome.com/img/cco.png">
          <noscript>
             "<img width="18" height="12" class="ls-flag" src="https://www.myhome.com/img/cco.png" >"
          </noscript>
     </a>
</li>

谢谢。

这段代码可以完成工作:

let selector = $(".ls-slot-shortcode_actions a noscript");
let txt = selector.text();

console.log("before modification:" + txt)

let newtxt = txt.replace(/width=".*?"/, 'width="42"');
selector.text(newtxt);

console.log("after modification:" + selector.text())
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<li class="ls-slot-shortcode_actions">
  <a href="https://www.myhome.com">
    <img scr="https://www.myhome.com/img/cco.png">
    <noscript>
             "<img width="18" height="12" class="ls-flag" src="https://www.myhome.com/img/cco.png" >"
          </noscript>
  </a>
</li>

如果你有更多行,而你只想保留一个,你可以这样做:

let selector = $(".ls-slot-shortcode_actions a noscript");
let txt = selector.text();

console.log("before modification:" + txt)

let newtxt = txt.replace(/width=".*?"/g, 'width="xx"');
newtxt = newtxt.replace(/width="xx"/, 'width="42"');
newtxt = newtxt.replace(/"<img width=.xx. .+>"/g, "");
selector.text(newtxt);

console.log("after modification:" + selector.text())
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<li class="ls-slot-shortcode_actions">
  <a href="https://www.myhome.com">
    <img scr="https://www.myhome.com/img/cco.png">
    <noscript>
             "<img width="18" height="12" class="ls-flag" src="https://www.myhome.com/img/cco.png" >"
             "<img width="18" height="12" class="ls-flag" src="https://www.myhome.com/img/cco.png" >"
             "<img width="18" height="12" class="ls-flag" src="https://www.myhome.com/img/cco.png" >"
             "<img width="18" height="12" class="ls-flag" src="https://www.myhome.com/img/cco.png" >"             
          </noscript>
  </a>
</li>