我在2013年的平台上有一个新闻自动收录机工作得很好,但是当我没有新闻时,横幅仍然是空的,我怎么能隐藏它? 这是我的代码:jquery.ticker.js 并且:
<script type="text/javascript">
$(document).ready(function() {
var soapEnv = "soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \ <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>supported_applications</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
<FieldRef Name='ID' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "path to.../_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
function processResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
// var liHtml = $(this).attr('ows_ID') +": " +$(this).attr('ows_Title')+'<br>'; var liHtml = "<li><a href='path to.../Lists/applications/DispForm.aspx?ID=" + $(this).attr('ows_ID') + "'>" + $(this).attr('ows_Title') + "</a></li>";
$("#tasksUL").append(liHtml);}); }
</script><ul id="tasksUL"/>
任何建议?
答案 0 :(得分:0)
如果count为空,则隐藏包含的html元素。
function processResult(xData, status) {
if( $(xData.responseXML).find("z\\:row").length==0)
{
$("#tasksUL").hide();
}
$(xData.responseXML).find("z\\:row").each(function() {
// var liHtml = $(this).attr('ows_ID') +": " +$(this).attr('ows_Title')+'<br>'; var liHtml = "<li><a href='path to.../Lists/applications/DispForm.aspx?ID=" + $(this).attr('ows_ID') + "'>" + $(this).attr('ows_Title') + "</a></li>";
$("#tasksUL").append(liHtml);}); }