0

when click on button call function and display div mac_1, after that when click on run button click function and call three times, how to set if condtion by div id

$("#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());

on click button call 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>
  • start here - https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics – Jaromanda X Sep 02 '15 at 09:57
  • You need an `if(condition)` to return true/false before you can check if your new condition is true/false `else if()` that will enable the `else` to execute if non of the conditions return true. – NewToJS Sep 02 '15 at 10:00

2 Answers2

0

That should work. Maybe capturePhoto() has a bug? Insert an alert() or 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

Community
  • 1
  • 1
Ivin Raj
  • 3,448
  • 2
  • 28
  • 65
0

Make your question clear first .

As far as I understood you want to get the button element id when the button is clicked. Is my understanding correct ?

If it is then follow the code below ,

Each event will have different properties associated with it and one of them is target.The target event property returns the element that triggered the event.

So on click of button you can get the element which triggered the event as event.target

If you want ID event.target.id will help you.

AvinashK
  • 13
  • 4