Javascript 如何使用jquery将类值从弹出窗口传输到父窗口
我想从弹出窗口到父窗口获取类名。如果我的弹出窗口显示instagram页面,并且我单击了follow按钮,则follow按钮的类别将更改。我想,如果我在我的父窗口中点击follow按钮,则按+1点计算follow。如果我没有点击follow按钮并关闭弹出窗口,那么follow将不会计入我的父窗口 有人能用一些jquery代码来解决这个问题吗?Main:Javascript 如何使用jquery将类值从弹出窗口传输到父窗口,javascript,php,jquery,Javascript,Php,Jquery,我想从弹出窗口到父窗口获取类名。如果我的弹出窗口显示instagram页面,并且我单击了follow按钮,则follow按钮的类别将更改。我想,如果我在我的父窗口中点击follow按钮,则按+1点计算follow。如果我没有点击follow按钮并关闭弹出窗口,那么follow将不会计入我的父窗口 有人能用一些jquery代码来解决这个问题吗?Main: <html lang="en"> <body> <span id="followerCount"&
<html lang="en">
<body>
<span id="followerCount"></span>
<br/>
<button onclick="openPopup()">Open Popup</button>
</body>
<script type="text/javascript">
let followerCount = 999;
writeFollowerCount();
function writeFollowerCount() {
document.getElementById('followerCount').innerText = followerCount.toString();
}
function openPopup() {
window.open('popup.html', 'mypopup', 'width=500,height=300');
}
function follow() {
followerCount++;
writeFollowerCount();
}
</script>
</html>
打开弹出窗口
让followerCount=999;
writeFollowerCount();
函数writeFollowerCount(){
document.getElementById('followerCount')。innerText=followerCount.toString();
}
函数openPopup(){
window.open('popup.html','mypopup','width=500,height=300');
}
函数follow(){
followerCount++;
writeFollowerCount();
}
弹出窗口:
<html lang="en">
<body>
<button onclick="follow()">Follow</button>
</body>
<script type="text/javascript">
function follow() {
window.opener.follow();
window.close();
}
</script>
</html>
跟随
函数follow(){
window.opener.follow();
window.close();
}
欢迎来到stackoverflow。请发布您已经完成的操作。显示按钮单击功能的代码