Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Модифицировать функцию (https://javascript.ru/forum/jquery/30138-modificirovat-funkciyu.html)

kiberkot 25.07.2012 13:11

Модифицировать функцию
 
Помогите модифицировать функцию. Нужно чтобы каждое значение выводилось в отдельны span.

Примерно так:
var text = '';
$.each(values, function(i, val){
  text += '<span class="span' + i + '">' + val + '</span>';
});
$('#result').html(text);



Код функции:

$(function(){
	jQuery.support.cors = true;
	$.get("http://honladder.appspot.com/stats/cis/Mortanius/casual", function() { return; })
		.complete(function(data, status){
			$('#status').html(status);
			$('#error').html('Complete: no error');
			var pattern = /span class=\"value\"\>([\.0-9]*)\<\/span\>/gi;
			var item;
			var text = '';
			while ( item = pattern.exec(data.responseText) ) {
				text += item[1] + ', ';
			};
			$('#data').text(text);
		}, 'text')
		.success(function(data, status){
			$('#status').html(status);
			$('#error').html('Success: no error');
			$('#data').html($(data).find('span').length);
		})
		.error(function(data, status, error){
			$('#status').html(status);
			$('#error').html(error);
			$('#data').html(data);
		});
});


Часовой пояс GMT +3, время: 04:24.