If you want to hide a specific div on a specific page of your website, you can do it with JQuery, using the below code.

Example: if your page URL is “http://www.example.com/about.php”

The first block of code will give you “about.php” from your full URL and store it in the variable called “current_page_name”.

Then in the second block of code you compare your desired page name (in this case: “about.php”) with the variable “current_page_name”, and if they match, you can hide your desired div with this code “$(“#hide-div-id “).hide();”

The complete code is shown below:

$(document).ready (function () {

/* Get current page URL and NAME */

var current_page_url = window.location.href;

var current_page_id=current_page_url.split(“/”);

var current_page_name = current_page_id[(current_page_id.length)-1];

/*Hide div “#hide-div-id” on your desired page*/

if(current_page_name==’your-desired-page-name.php’){

$(“#hide-div-id “).hide();

}

});

Latest posts by Soumyajit Dutta

  • Share/Bookmark