我怎么能发现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" /> <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包含图像,如果包含那么我还要做更多的事情。
答案 0 :(得分:0)