Reputation: 1605
I have two pages, say page1.jsp and page2.jsp and a common javascript file script.js.
I have an onclick call in page1.jsp like this:
<td><a href="#" onclick="onTab_ServiceTypes();">004</a></td>
and this method is in script.js defined as:
<script>
function onTab_ServiceTypes() {
// Here I want to hide a div of page2.jsp, like this
$("#div_of_page2JSP").hide();
}
</script>
How can I do this?
Upvotes: 0
Views: 299
Reputation: 38645
If I understand your question right this is not possible. You won't be able to manipulate elements not within the current DOM with JavaScript. You could probably pass a variable in your URL like page2.jsp?hideDiv=true
(You would have a better name for this variable...) when you click the link and navigate to page2.jsp
and hide div
on page load.
Upvotes: 2
Reputation: 388316
you can't do that if both pages are independent(page2 is loaded via a page reload).
What you can do is to store the clicked state using a cookie/web-storage(local storage/session storage) then when the second pages is loaded check the state of the stored value and then hide/show those elements.
Upvotes: 3