开发者

How to match text with jquery or partial matching

开发者 https://www.devze.com 2023-01-03 22:53 出处:网络
I have this hyperlink in anchor tag <a href=\"/index.php?var1=rule-power\" > Text </a> 开发者_如何学Go

I have this hyperlink in anchor tag

<a href="/index.php?var1=rule-power" > Text </a>
开发者_如何学Go

Now i want that when that page is clicked i have the page with hyperlinks like

<a href="" >rule-power </a>

Is it possible that i can grab the var1 using jquery . even if its partial match it willl be good and then remove that tag

something like

NewVar =getParameter(var1);
$.find(a).withtext(NewVar).hide()


You can use Artem Barger's answer here to get the querystring variable, then you can use :contains() to do a partial match, like this:

var var1 = getParameterByName('var1'); //from linked answer
$('a:contains("' + var1 + '")').hide();

Or, if you wanted an exact match, use .filter() and .text(), like this:

var var1 = getParameterByName('var1');
$('a').filter(function() { 
  return $(this).text() == var1;
}).hide();
0

精彩评论

暂无评论...
验证码 换一张
取 消