1
임의의 목록 집합을 표시하려면 어떻게합니까 항목이 있다고 생각합니다. 감사합니다.랜덤 디스플레이의 NULL 표시
// 객체의 li 수를 계산하십시오. var listCount = $ ("li.contentBlock", obj) .length;
//Generate a random number from the count of li's
var randomListNumber = Math.floor(Math.random() * listCount -1);
//Generate list of items based on the amount of li's that are present
var firstList = "<li class='contentBlock'>"+$("li:eq("+randomListNumber+")", obj).html()+"</li>";
//Target element that contains that list
var place = $("ul", obj).html();
//Combine ul container and list generate
var newPlace = firstList+place;
//Replace current ul and li with newly generated random list
$("ul", obj).html(newPlace);
명확히하십시오. – Zaz
페이지로드시 임의로 ul 내의 목록 항목을 생성하려고합니다. obj는이 콘텐츠 갤러리에 대한 var입니다. – Chris