-2

我怎么能找到 div li 是否包含图像,如果它已经对其进行了一些操作,我尝试了很多方法,但我失败了。我像这样通过ajax上传图像我有一个显示所选div的按钮但是我在这个图像附加到点击事件时采取了一些行动

 <div id="display_img4" style="float: left; margin-left: 15px;"><li></li>
  </div> 
 but this code is useless             

$(document).ready(function(){
$('<li></li>').appendTo('#display_img4').html('<img src="<?php echo base_url();?>apps/screen_shots/'+response+'" alt="No image Found" height="75" width="75"/>').addClass('success');
}
<script type="text/javascript">

var img5= $('div#display_img4 > li.success > img');
var li  = $('div#display_img4 > li');var li_img =$('div#display_img4 > li').('img');if(li_img > 0 ){
            img.css("float","right");

            }

            else{ 

                    alert("not image")
             }


</script>
</div>

现在这是我的全部情况。

$(document).ready(function(){
 <?php foreach($edit as $rows){ ?>
    <?php foreach($screenshots as $inner_row){ ?>
var btn_screenshot3    = $('#upload-sc3');
    var status_screenshot3 = $('#status_screenshot3');
    var screenshot3        = $('#display_img6');
    var addbtn2         = $('#btn-add2');
    var rembtn2         = $('#rem2');
    var screentxt2      = $('#screen-txt2-admin');
    var container3      = $('#container3');

        var screenshot3=<?php echo (file_exists('apps/'.$rows->application_id.'/sc_3'.$inner_row->screenshot3) ? "true" : "false" ); ?>;
        if(screenshot3 == true){
            $('div#container3').css("display","block");
            $('#rem5').css("display","none");
            $('#rem4').css("display","none");
            $('#rem3').css("display","none");
            $('#rem2').css("display","none");
            $('#rem1').css("display","none");
            $('#upload-sc3').css("display","none");
             $('#screen-txt2-admin').css("display","none");
                $('<li></li>').appendTo('#display_img6').html('<img src="<?php echo base_url();?>apps/<?php echo $rows->application_id; ?>/sc_3<?php echo $inner_row->screenshot3; ?>" alt="No image Found" height="75" width="75"/>').addClass('success');

        $('#screenshot3').html('<input type="hidden" value="<?php echo     $inner_row->screenshot3; ?>" name="screenshot3" id="screenshot3" /><img src="<?php echo   base_url();?>images/remove.jpg" alt"Remove btn" onClick=deleteFileScreenshot3("sc_3<?php echo $inner_row->screenshot3; ?>","apps/<?php echo $rows->application_id; ?>/");>');

                btn_screenshot3.css("display","none");      

                screentxt2.css('display', 'none');
}else{

        $('#btn_add_more').css("display","block");
        $('#rem2').css("display","block");

        }

这是我的ajax调用

$(function(){
    var btn_screenshot3    = $('#upload-sc3');
    var status_screenshot3 = $('#status_screenshot3');
    var screenshot3        = $('#display_img6');
    var comm_txt           = $('#screen-txt2');
    new AjaxUpload(btn_screenshot3, {
        action: '<?php echo base_url();?>index.php/apps/apps/add_screenshot3',
        name:   'screenshot3_image',
        onSubmit: function(file, ext){
             if (! (ext && /^(gif|jpg|png)$/.test(ext))){    
                screenshot3.html('');
                status_screenshot3.text('Only gif|jpg|png files are allowed');
                status_screenshot3.css("color","red");
                screenshot3.html('');
                return false;
            }               

        },
        onComplete: function(file, response){
            <!--status_screenshot3.text(file);-->
            screenshot3.html('');
            status_screenshot3.css("color","black");
            status_screenshot3.html('');
            if(response!= ""){

                $('<li></li>').appendTo('#display_img6').html('<img src="<?php echo base_url();?>apps/screen_shots/'+response+'" alt="No image Found" height="75" width="75"/>').addClass('success');

                $('#screenshot3').html('<input type="hidden" value="'+response+'" name="screenshot3" id="screenshot3" />&nbsp;&nbsp;<img src="<?php echo base_url();?>images/remove.jpg" style=" margin-top:10px;" title="Delete" onClick=deleteFileScreenshot3("'+response+'","apps/screen_shots/");>');
                btn_screenshot3.css("display","none");

                comm_txt.css("display","none");

                $('#sc3').hide();

    } else{
                status_screenshot3.css("color","red");
                status_screenshot3.css("margin-left","190px");
                status_screenshot3.text('Images are allowed with dimension maximum 400 X 800  and minimum 250 X 500');

            }
        }
    });     
});

这是我要附加图像的 HTMl 代码

<div id="display_img6" style="float: left; margin-left: 15px;">

                           <li></li>

                          </div>

这段代码工作正常,现在我如何找到包含图像的 div li,如果包含,我会在上面做更多的事情。

4

1 回答 1

0
  1. 您要在 div 中添加您的 javascript 吗?
  2. 您不能在 javascript 中添加 PHP 脚本并期望它动态运行。PHP/JSP 脚本仅在页面构建时运行一次。
  3. 你的 AJAX 调用在哪里?
于 2012-10-31T06:29:16.810 回答