Reputation: 298
lets say im on this page
http://MyWebSite.com/users
and there is a link button on this page lets say
<span class="user">
<a href='{$record->url()}' id="main" class="Small">go to page</a>
</span>
If i click on the link it goes to for example
http://MyWebSite.com/users/jake
So now when im on this page there is same button exists and i want to hide it using javascript or jQuery :)
More info: The {$record->url()}
in the link is dynamic goes to a page depending on the user, so i must use {$record->url()}
in the script to match the current page link
Is this possible?
Upvotes: 0
Views: 510
Reputation: 76557
You could use jQuery's equals selector to hide any elements that had an href
attribute that pointed to your target page using the following code :
// This assumes that the URL will be populated via your server-side code in
// { ... } braces
$('[href="{$record->url()}"]').hide();
likewise, if you just wanted to hide any elements that pointed to the current URL, you could do the same thing via a bit of string concatenation :
// This would hide any elements that point to the current URL
$('[href="' + window.location.href + '"]').hide();
If you can avoid it though, you may want to consider hiding this using server-side code (i.e. using a conditional to determine when certain elements should / should not be rendered).
Upvotes: 0
Reputation: 8425
(I'm on a phone so this is the best I can do for now)
if (window.location.href.replace(location.hash,'') == "http://kodeweave.sourceforge.net/editor/") {
$(".nicole").hide()
} else {
$(".michael").hide()
}
Upvotes: 1