1.父窗口操作页面嵌套的iframe
①操作iframe的标签属性
//使用onload事件在iframe加载完毕后进行操作
$("#要操作的iframe绑定的id").load(function(){
document.getElementById('要操作的iframe绑定的id').contentWindow.document.getElementById('iframe内部的标签绑定的id').XXX = XXX
})
②iframe调用父窗口的方法
parent.window.方法名();
③父窗口调用iframe的方法
document.getElementById('iframe的id').contentWindow.子页面的方法;
④父窗口设置子窗口iframe的变量值
document.getElementById('iframe的id').contentWindow.变量名 = XXX
2.同一个标签页中存储公用的变量可以使用sessionStorage
//注意,只能存储字符串
//存储键值对
sessionStorage.setItem('key','value');
//根据key值获取value
sessionStorage.getItem('key');
3.通过点击事件触发方法来设置按钮的显示和隐藏
function name(){
//根据id设置隐藏
$('#id').hide();
//根据id设置显示
$('#id').show();
}
4.判断指定div是否显示
//flag为true则为显示,为false则为隐藏
let flag = $('#id').is(':visible');