Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy is my if/else not working
    primarykey
    data
    text
    <p>im trying to search my page for an iframe which doesn't have the attribute 'current' set as 'current'.</p> <p>(the current attribute is set when the iframe is being used, and reset once its loaded).</p> <p>I'm trying to code so that IF there is 1 or more iframes not set as current, use one of them, ELSE, create a new iframe, do some other stuff and use the new one,</p> <p>but this code isn't quite working, I never trip the 'alert', so I'm never going into the ELSE part even though I know I have no iframes who's 'current' attribute isn't set,:</p> <pre><code>var $fi = $visible.find(".file-info"); thisPreview = {}; var iframes = $('iframe').filter(function (index) { return index == 0 || $('iframe').attr("current") == "no"; }) if(iframes.length &gt;0){ //if one of the iframes hasnt got current set as current, use it var theSuffix = iframes.attr('id').split('_').pop(); thisPreview[theSuffix] = $fi.prev(".image-preview"); $(this).closest(".file-upload-form").children(".variable-hidden").attr('value',theSuffix); iframes.attr('current','current'); $(this).closest('.file-upload-form').attr('target','upload_target_'+theSuffix); } else{//else, create a new iframe, quick! var count = $('[id^="upload_target_"]').length(); alert(count); var countPlus1 = count+1; iframe = $('&lt;frame&gt;').attr({'id':'upload_target_'+countPlus1,'name':'upload_target_'+countPlus1,'current':'current'}).addClass('upload-target'); iframe.appendTo($('#container')); thisPreview[countPlus1] = $fi.prev(".image-preview"); $(this).closest(".file-upload-form").children(".variable-hidden").attr('value',countPlus1); $(this).closest('.file-upload-form').attr('target','upload_target_'+countPlus1); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload