I just posted an answer to another question about how to do it.
In your case, assuming you used body_class() in your theme, your home page should have a <body> with class home to it.
So in your JS, you can:
if( $('body.home').length ){
// Do stuff
}
Related Posts:
- Custom post type and body_class: Remove “blog” class
- Storing posts from query and accessing later via AJAX call
- JS innerhtml changing style when using AJAX
- Side effects of Script and Iframe in post
- Redirect to another page using contact form 7? [closed]
- Posts are not rendering perfectly [closed]
- Passing total post count to javascript
- Default post showing more than intended
- Add extra parameters after permalink?
- Limit the word count in the post title
- Correct Post Count ( All | Published | Drafts | Pending | Trash ) for Custom Post Type when restricting to view own posts
- How do I write this SQL statement for Posts written in last 24 hours?
- 960gs different classes on teasers posts
- Structuring a product catalogue in WordPress [closed]
- How can I fix a slow redirect after form submit from frontend (no plugin)?
- Calculate Repeater Meta Box Input Field Values and Display Total
- How to localize value of posts
- Change Post Title Edit Box
- How to delete all posts from a custom post type?
- Update content of multiple pages/posts at once?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- CPT’s archive and single page not working [closed]
- Trying to edit the single page from a Custom Post
- How to Submit Post Via cURL & PHP
- apply filters only to specific post listing without check the url parameters
- is there a way to retrieve posts that do not have a featured image assigned?
- Post image in WordPress not appearing on home page
- Create new custom post and post category of same name
- Load Next WordPress Posts With AJAX?
- Combine multiple getEntityRecords calls
- Is it a good idea to add a column to the posts table?
- If there is only one post (show elements) else (show other elements)
- Creating separate feeds for custom post types
- Custom post type menu
- wordpress lists similar type of posts in a custom post type
- Modify Posts from Custom_Post_Type within the plugin
- One Site. One Theme. Multiple Stylesheets without plugins?
- How do I edit the WordPress post.php file?
- How I can made a custom post type to page templates?
- Easy reading or transfer of data from posts?
- List all posts in taxonomy term
- list posts of two post types in a single template
- The loop does not show users
- how to redirect to a custom post template
- Post/Custom Post Type URL Access
- Front-end Image Upload to Custom Meta Box
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- Adding /blog in front of single posts (only)
- Invalid content when I try to import custom post type from the old template wordpress
- Add a form in every post and save data in post meta
- list articles in admin showing nested categories or slugs?
- Search CPT by tag ids
- Post template with breadcrumb needs to show page navigated from
- URL issue retrieving Custom Post Types using Backbone JS API
- Right way to store a large set of similar information on website? [duplicate]
- Define multiple prefixes for custom post type
- Publishing failed. The response is not a valid JSON response
- add all blog posts to folder
- Correct way adding External classes to Custom Post type and output their methods to template
- Show posts from WP Custom Post Type selected from a field in a metabox
- Custom post type not pulling CSS
- Hide the update button from edit view in wordpress custom post type
- order custom post type posts by custom date
- How to show posts of the same category on a page?
- Assign a Post to a User
- Cannot save pages after migration
- custom post type to post association in wordpress
- Rest Api not working with Iframe in form data
- Need to display author’s email id in the “Edit post” field in wp dashboard. How do I do this?
- Use WP pagination functions on a custom page template
- How to get all posts related to a taxonomy?
- How to make sure, that only the selected post is changing?
- call a function when insert and update a custom post type
- Work and Display a Custom Post Type as a normal Post
- Most efficient way of showing children posts?
- Limit or filter edit view in the dashboard to a specific ID only?
- Custom post type with two templates
- One Post with different content, depending on a Page
- Custom Post Type
- Why isn’t my custom post type using the corresponding custom post template?
- Popup panel is only displaying 1 entry ignoring all others
- Custom Post Status & Taxonomies
- How to display data with pagaination on backend?
- Edit post meta direct from post.php?
- How to Arrange Support => Thumbnail
- Front-end form submission not creating post
- Linking custom taxonomies and posts
- Post being scheduled that shouldnt be schedulded
- Post type cloud like tag cloud?
- Change permalinks for posts but not custom post type?
- Get custom post type parent category
- How to delete unnecessary custom post types in the UI
- WordPress custom post type odd and even styling [duplicate]
- show the most recent date of all posts to display on front end
- Error 403 when posting comments to a custom post type from a different page
- How to automate the creation of advanced layout article/post
- Display code if title of the custom post matches title of other post
- Hide load more button if no more post in selected category
- Display posts of only a certain category in WP Admin section?
- Post current post type to my Ajax