Hide HTML Content Based on Page URL?

Is there a way to use jQuery to hide specific elements based on the Page URL? I’m trying to hide specific content based upon only one user’s profile, and the only thing that seems unique is the page URL.

Thank you in adavance!

Consider this:

	$(function()
		{
		var pathname = window.location.pathname;	// or use location.search if you want to get the query string
		if (pathname == "/admin.php")				// for example
			{
			console.log ("on admin page, hiding results ID");
			$("#results").remove(); // or .hide(), depending on your definition of "hide"
			}
		else
			console.log ("not on admin page, page=",pathname);
		});
1 Like

That worked splendidly! Thank you, @tracknut!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.