Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击index.html中的按钮时,如何隐藏products.html页面中的某些元素?_Javascript_Jquery_Html_Filter_Hide - Fatal编程技术网

Javascript 单击index.html中的按钮时,如何隐藏products.html页面中的某些元素?

Javascript 单击index.html中的按钮时,如何隐藏products.html页面中的某些元素?,javascript,jquery,html,filter,hide,Javascript,Jquery,Html,Filter,Hide,我知道要在同一页面中隐藏元素,我必须执行以下操作: $('#district-collection').click(function(){ $('.hemisphere').hide(); }); 我的问题是。半球体在我的products.html页面中,index.html没有看到它 您需要一个位置来存储要隐藏的元素的类,并在加载该页面时检索该类并隐藏该元素。尝试使用本地存储。如何呈现products.html页面?导航是如何发生的?如果将console.log添加到函

我知道要在同一页面中隐藏元素,我必须执行以下操作:

 $('#district-collection').click(function(){ 
       $('.hemisphere').hide();

 });

我的问题是。半球体在我的products.html页面中,index.html没有看到它

您需要一个位置来存储要隐藏的元素的类,并在加载该页面时检索该类并隐藏该元素。尝试使用本地存储。如何呈现products.html页面?导航是如何发生的?如果将console.log添加到函数中,处理程序是否工作?也许您需要等待页面加载并将其设置为$document.ready.1。将console.log'something'放在函数中的任意位置,以查看是否触发了它。如果未触发,请查看选择器是否实际工作;2个试验半球可在所有试验中选择js@JRodDynamiteJSFIDLE不太适合演示不同html页面之间的导航。