所以,我需要从主页面关闭div,并从加载的页面按钮。jquery - 从加载页面隐藏父div,
这是主要的网页:
<div id="DIV1" style="display:none;"></div>
<div id="ShowPage1">Show 1</div>
<div id="ShowPage2">Show 2</div>
<script type="text/javascript">
$('#ShowPage1').click(function(){
$("#DIV1").load("test1.html");
$("#DIV1").show();
return false;
});
$('#ShowPage2').click(function(){
$("#DIV1").load("test2.html");
$("#DIV1").show();
return false;
});
</script>
这是test1.html
<div id="HideDIV1">HideDiv</div>
<script type="text/javascript">
$('#HideDIV1').click(function(){
$("#DIV1").hide();
return false;
});
</script>
第一部分,很好地工作,将其加载test1.html并显示DIV1。 发布时,我尝试从test1.html隐藏它#HideDIV1,...只是不工作。
请帮忙。
是否来自test1.html的javascript实际运行?尝试在其中放入一个alert()或console.log()来检查它。 – Sebastianb
是的,带有alert()工作 –
尝试''('#HideDIV1')on('click',function(){$('#DIV1')。hide(); return false;});' – 2016-03-04 18:46:06