【发布时间】:2015-08-25 22:46:56
【问题描述】:
我的目标很简单——我想在下一个空的 div 中添加一张图片。 例如,我有三个 div。如果第一个 div 不为空,我想给第二个 div 添加一张图片。
所以,我有一个非常简单的看法:
<div id="imageDivF"></>
<div id="imageDivSecond"></>
<div id="imageDivT"></>
一个非常简单的局部视图:
<img id="hello"/>
将部分视图加载到 div 中的 AJAX 代码:
$(document).ready(function () {
datatype:'json',
url: '/Home/UploadFiles',
autoupload: true,
done: function (e, data) {
if ($("#imageDivF").has("img").length==0)
{ $('#imageDivF').load('/Home/ImagePartialView', { address: data.result.name });
// in this next row I would like to check whether #imageDivF contains image
//I should check whether #imageDivF contains image to decide whether it is necessary to put image to the next empty div
//pseudo code: if(#imageDivF) does not contain image, then image should be inserted to the next div #imageDivSecond
}
如何检查“#imageDivF”是否包含局部视图(内部图像)? 我试过的:
$('#imageDivF').find('#hello');//not detected
$(''hello", "'#imageDivF")// not detected
$('#imageDivF #hello')// not detected
【问题讨论】:
标签: javascript jquery ajax asp.net-mvc asp.net-mvc-4