替换Javascript中的某个字符
目前正在运行此脚本(原作者不再支持它):
http:// Askthecssguy.com/articles/checkbox-filters-with-jquery/
如果您有一个标签(这些标签通常构成每个复选框),其中包含空格(如果您有空格,则它可以正常工作)创造多个标签)。解决这个问题的唯一方法是使用下划线,这很好,但在渲染的页面上看起来很垃圾。我想知道运行此脚本后是否有办法从某些
类中删除所有 _
并用空格“”替换它们。抱歉,如果这令人困惑!
Am currently running this script (the original author is no longer supporting it):
http://askthecssguy.com/articles/checkbox-filters-with-jquery/
This works fine apart from if you have a tag (these in tern make each of the check boxes) which has spaces in it (if you have spaces it creates multiple tags). The only way to get around this is by using underscores which is fine however looks rubbish on the rendered page. I was wondering is there a way after this script is run to remove all _
from certain <li>
classes and replace them with a space " ".
Sorry if this is confusing!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的列表项元素应用了“tagFilter”类。然后,您可以执行以下操作,从列表项的文本中删除下划线:
但是请注意,这假设您的列表项不包含除文本节点之外的任何其他子节点。也就是说:
如果您有包含文本的列表项的特定子元素(例如标签元素),那么您可以执行以下操作:
Let's say your list item elements have a class "tagFilter" applied. Then you can do the following to remove underscores from the text of the list item:
Note, however, this assumes that your list item doesn't contain any other child nodes except a text node. That is:
If you have a specific child element of the list item that contains the text, say a label element, then you can do: