2017-02-27 13 views

答えて

1

これを試してみてください:)

var div_tot = $('div.item').length; //count total of divs 

$('div.item').each(function(i) { 
    var no = i+1; 
    $(this).find('span').text(no+'/'+div_tot); 
}); 
0

私はあなたのようなものが欲しいと思いますか?

var items = $("div.item"); 
var count = items.length; 
items.each(function(i){ 
    $(this).find("span")[0].firstChild.data = i.toString() + "/" + count.toString(); 
}); 
関連する問題