gpt4 book ai didi

javascript - 调用函数时如何设置if条件

转载 作者:行者123 更新时间:2023-11-28 07:16:04 25 4
gpt4 key购买 nike

点击按钮调用函数显示div mac_1,然后点击运行按钮点击函数调用三次,如何通过div id设置if条件

$("#run").click(function() {$('#resultFrame').contents().find('html').html("<style>" + $('#css').val() + "</style>" + $("#html").val());
document.getElementById('resultFrame').contentWindow.eval($('#js').val());
else if
{
$('#resultFrame1').contents().find('html').html("<style>" + $('#css').val() + "</style>" + $("#html").val());
document.getElementById('resultFrame').contentWindow.eval($('#js').val());
}
else
{
$('#resultFrame3').contents().find('html').html("<style>" + $('#css').val() + "</style>" + $("#html").val());
document.getElementById('resultFrame').contentWindow.eval($('#js').val());

点击按钮调用div

<div  class="mac_1"  id="mac_1" >
<iframe id="resultFrame" height="100%" width="100%">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
<div class="ipad_1" id="ipad_1" style=" display: none;">
<iframe id="resultFrame1" height="100%" width="100%">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
<div class="mob_1" id="mob_1" style=" display: none;">
<iframe id="resultFrame3" height="100%" width="100%">
<p>Your browser does not support iframes.</p>
</iframe>
</div>

最佳答案

那应该行得通。也许 capturePhoto() 有错误?插入 alert()console.log():

if ( photo=="yes" )
{
alert("Thank you StackOverflow, you're a very big gift for all programmers!");
capturePhoto();
}
else
{
alert("StackOverflow.com must help me!");
}

DEMO

关于javascript - 调用函数时如何设置if条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32350022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com