The JSP-ness is irrelevant once things get to the browser, so it all ends up being one page. So, yes, it should work.
Reasons it might not work:
Do you have more than one element with that id? id values must be unique on a page. It's best to avoid them and use class names rather than ids unless you know they are clearly intended to be, and will be, unique.
Are you sure that the element exists before this code executes? You could have a race condition.
Another reason why it might not work is that "$" is a magic character in the Java Expression Language. When in doubt, don't use "$" as the marker for a jQuery expression, use the long form ("jQuery.xxxx()").
An IDE is no substitute for an Intelligent Developer.
And, when debugging these things, always (always) look at what the browser is actually working with, not the JSP code.
As Bear says, this is not a JSP issue as such.
It's an issue with the code that lands on the browser, so embrace your browser's dev tools!
moose poop looks like football shaped elk poop. About the size of this tiny ad:
Download Free Java APIs to Work with Office Files and PDF