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()").
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
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!
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
ScroogeXHTML - the small and fast RTF to HTML converter library