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

标签 javascript html css

点击按钮调用函数显示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/

相关文章:

javascript - 如何使用 Angular 的装饰器模式来增强指令的链接功能?

javascript - "Amount"字段未传递到 PayPal

html - Bootstrap/浏览器宽度计算问题

html - 是否可以将图像放入输入类型 ="check box"?

Java FreeMarker : Replacing a ${variable} with a collection instead of an instance of an object

html - Safari SVG 线性渐变在 Safari 中不起作用

javascript - 如何切换具有持续时间和显示的 jQuery 元素?

javascript - Firebase 数据库删除所有等于特定值的节点

html - 我可以用 css3 和 html5 得到它吗? (渐变背景、边框渐变、透明度)

javascript - 在 box-shadow 属性上禁用 CSS 过渡