How to Hide a Specific Div On a Specific Page of Your Website With Jquery
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:
/* Get current page URL and NAME */
var current_page_url = window.location.href;
var current_page_name = current_page_id[(current_page_id.length)-1];
/*Hide div “#hide-div-id” on your desired page*/
Latest posts by Soumyajit Dutta
- Wordpress Plug-in For Showing Custom Menu Within A Post Or Page - September 19th, 2011
- Add Custom Input Fields In Custom Post Type Using Custom Field Template Plugin - August 10th, 2011
- WordPress Tutorial - June 14th, 2011
- Create Your Own Website For Free With Byethost.Com - April 12th, 2011
- Ideal Process to Organize Your Project - March 14th, 2011