http://pi.codele.se/php/debatt.php (json-formatted)에서 데이터를 검색하는 스크립트가 jQuery에 있습니다. 그리고 <div id="output">
안에 http://pi.codele.se/debatt.html?page=1 안에 반환됩니다. fetch/fetch.js에서 볼 수 있듯이 <div class = "box w-25 h-70 ">
을 반환합니다. 그러나 5 개의 DIV 클래스 사이에서 코드가 랜덤 화되기를 원합니다.다른 DIV 클래스를 출력하도록 jQuery를 만드는 방법은 무엇입니까?
Ex.
<div class="box w-25 h-70">
<div class="box 2">
<div class="box 3">
<div class="box 4">
<div class="box 5">
가져가 /이 같은
$(document).ready(function(){
var output = $('#output');
$.ajax({
url: 'http://pi.codele.se/php/debatt.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status){
$.each(data, function(i,item){
var content = '<div class="box w-25 h-70"><h3>'+item.rubrik+'<span>Publicerad '+ item.datum+'</span></h3>'
+ '<p>'+item.innehall+'<br></div></div>';
output.append(content);
});
},
error: function(){
output.text('Kolla din anslutning.')
}
});
});
내 즐거움! :) –