paulclift Posted August 23, 2017 Share Posted August 23, 2017 I am displaying data from one page in another page in the following way: <script> $(document).ready(function(){ $( "#2017" ).load( "data.html .2017" ); $( "#2016" ).load( "data.html .2016" ); }); </script> <div id="2017"></div> <div id="2016"></div> ...BUT I also need to be able to hide (onload) certain div classes from within the linked file... <script> $(document).ready(function(){ $('.private-files').hide(); }); </script> I know that the code above will hide divs by class if they are contained in the main page, but how can I make it so that divs of class 'private-files' in 'data.html' will also be hidden? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 23, 2017 Share Posted August 23, 2017 You need to run the code to hide the elements after adding them to the page. Hopefully that load method has a callback function you can use for that. Link to comment Share on other sites More sharing options...
paulclift Posted August 23, 2017 Author Share Posted August 23, 2017 @justsomeguy Thanks for your response. I am not particularly knowledgable with JS .... could you describe your solution in a little more detail please? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 23, 2017 Share Posted August 23, 2017 The documentation for jQuery's load method is here: http://api.jquery.com/load/ You can see from some of the examples that you can pass a callback function to load also. The callback function gets called after the load has finished. Inside that callback function you can run the code to hide the new elements that were just added. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now