简体   繁体   English

如何在两者之间更改文本<li> WordPress 中的 jQuery 标签?

[英]How to change text between <li> tags with jQuery in WordPress?

I am using WPML plugin to translate a website and I have a plugin that does not seem have the kind of strings that can be translated.我正在使用 WPML 插件来翻译一个网站,我有一个插件似乎没有可以翻译的字符串类型。

What I want to do is change the text 'Nici un rezultat...' between the 'li' tags in the following code using jQuery.我想要做的是使用jQuery更改以下代码中“li”标签之间的文本“Nici un rezultat...”。 Or do you suggest other method?或者你建议其他方法?

<div id="aws-search-result-1" class="aws-search-result" style="width: 225px; top: 339.828px; left: 1026.03px; display: block;">
   <ul><li class="aws_result_item aws_no_result">Nici un rezultat...</li>
   </ul>
</div>

Here is my full code https://codepen.io/SilviuIsidor/pen/gGdxMg and here is the actual webpage: https://isidors.com/test/dupex/en/store/这是我的完整代码https://codepen.io/SilviuIsidor/pen/gGdxMg ,这是实际的网页: https : //isidors.com/test/dupex/en/store/

How can I do it?我该怎么做?

Use jQuery function .text()使用jQuery函数.text()

 $("ul li").text("Your new Text");
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="aws-search-result-1" class="aws-search-result" style="width: 225px; top: 339.828px; left: 1026.03px; display: block;"> <ul><li class="aws_result_item aws_no_result">Nici un rezultat...</li> </ul> </div>

This will change the text of all the li tags for an advanced selection(ex: first li tag, last li tag, nth child ...) use the jQuery Selectors这将更改高级选择的所有li标记的文本(例如:第一个li标记、最后一个li标记、第 n 个子项...)使用jQuery 选择器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM