且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从标签中的href获取查询字符串参数

更新时间:2023-02-24 10:42:05

You could use Attribute Contains Selector [name*="value"] "a[href*=fruit]" to select a elements that contain "fruit" at href attribute, .attr(attributeName, function) , String.prototype.replace() to replace "apple" with "orange"

$("a[href*=fruit]").attr("href", function(_, href) {
  return href.replace(/apple/, "orange")
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<a href="http://www.domain.com/page/other.jsf?fruit=apple&tree=pine&rock=sedimentary">click me</a>

上一篇 : :ServiceStack响应过滤器“短路"造成问题下一篇 : 如何在struts tile中获取原始url

相关阅读

技术问答最新文章