I've got some jQuery that interacts with items on the post and page editor screens. However, the script is also loading on other admin screens that are driven by post.php
Is there a way to target the post/page editor screen exclusively?
I'm currently using:
global $pagenow;
if( 'post.php' == $pagenow )
{
//jQuery blocks go here
}
However, since the jQuery has refences to objects that only appear on the post/page editor screens, I'm getting console errors on other pages that are driven by post.php
For example, this code throws a console error of "Uncaught TypeError: Cannot read property 'length' of undefined":
var charactersMeta = jQuery("#excerpt").val().length;