Title: Adding Class current_page_item to main menu using Javascript
Last modified: August 19, 2016

---

# Adding Class current_page_item to main menu using Javascript

 *  [LMcGhee](https://wordpress.org/support/users/lmcghee/)
 * (@lmcghee)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/adding-class-current_page_item-to-main-menu-using-javascript/)
 * Hi!
 * I am trying to use javascript to make a page entitled Projects “active” when 
   on each the single post page.
 * I am placing this code on the top of the single.php before it gets the header(
   which includes the project link).
 * <script>
    jQuery(document).ready(function(){ $(“#menu-item-19”).children(“a”).
   addClass(“current_page_item”); }); </script>
 * Where #menu-item-19 is the id of the li that includes the link to the projects
   page.
 * Any idea why the link isn’t getting the class “current_page_item”?
 * Thanks in advance!

Viewing 1 replies (of 1 total)

 *  [Devin Price](https://wordpress.org/support/users/downstairsdev/)
 * (@downstairsdev)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adding-class-current_page_item-to-main-menu-using-javascript/#post-1998273)
 * It should work. WordPress applies the class to the “li” though, rather than the“
   a”, so perhaps that’s where the conufsion was.
 * $(‘#menu-item-19’).addClass(‘current_page_item’);

Viewing 1 replies (of 1 total)

The topic ‘Adding Class current_page_item to main menu using Javascript’ is closed
to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [Devin Price](https://wordpress.org/support/users/downstairsdev/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/adding-class-current_page_item-to-main-menu-using-javascript/#post-1998273)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
