我在HTML / JS / CSS写了一个简单的测验。它工作正常,到目前为止,但是当我把它嵌入到iframe到我的网站,该按钮(div的)都没有在iPhone上点击。当我查看测验不IFRAME,一切完美。
所以,也许这是一个iFrame的问题?
在HTML / CSS标记是非常简单的。
任何帮助表示赞赏 - 感谢球员
body {
background: #80B6AE;
}
.button {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
text-decoration: none;
font-size: 18px;
font-weight: 400;
line-height: 22px;
height: 50px;
margin-top: 12px;
transition: 0.3s;
cursor: pointer;
background-color: #FFF;
color: #000;
}
.button:hover {
background-color: #e0e0e0;
}
<!-- BUTTON A -->
<div class="button" onclick="tlPlay(1, '')">Lorem ipsum dolor sit amet</div>
<!-- BUTTON B -->
<div class="button" onclick="tlPlay(1, 'correct')">Lorem ipsum dolor sit amet</div>
使用contents()
访问一个iframe中的文档对象。请注意,在一个文档中使用jQuery库来操纵另一个文档的一般问题,因此一般应避免。然而,在结合事件的情况下,它的工作。
<iframe name="temp_iframe" width="100%" height="95%" src="'+the_url+'"></iframe>
$('[name=temp_iframe]').contents().find('button').click(function() {
alert('click');
});
你可以找到答案这个link也