Return to Snippet

Revision: 57479
at May 28, 2012 15:51 by StrawMan


Updated Code
//Colorize Portions Of String
$('div.tr_history_use_sub_div').each(function() {
	var $text = $(this).text();
	if($text.indexOf('+') >= 0) {
		$(this).css({
			'color' : 'green'
		});
	} else if($text.indexOf('-') >= 0) {
		$(this).css({
			'color' : 'red'
		});
	}
	var go_pos = $text.search(/ゴールド/i);
	var go_txt = $text.substr(go_pos, 4);
	if(go_txt === 'ゴールド') {
		var t = $(this).text();
		t = t.replace(go_txt, '<span class="gold_black">ゴールド</span>');
		$(this).html(t);
	}
});

Revision: 57478
at May 28, 2012 15:50 by StrawMan


Updated Code
//Colorize particular results.
$('div.tr_history_use_sub_div').each(function() {
	var $text = $(this).text();
	if($text.indexOf('+') >= 0) {
		$(this).css({
			'color' : 'green'
		});
	} else if($text.indexOf('-') >= 0) {
		$(this).css({
			'color' : 'red'
		});
	}
	var go_pos = $text.search(/ゴールド/i);
	var go_txt = $text.substr(go_pos, 4);
	if(go_txt === 'ゴールド') {
		var t = $(this).text();
		t = t.replace(go_txt, '<span class="gold_black">ゴールド</span>');
		$(this).html(t);
	}
});

Revision: 57477
at May 28, 2012 15:50 by StrawMan


Updated Code
//Colorize portions of string.
$('div.tr_history_use_sub_div').each(function() {
	var $text = $(this).text();
	if($text.indexOf('+') >= 0) {
		$(this).css({
			'color' : 'green'
		});
	} else if($text.indexOf('-') >= 0) {
		$(this).css({
			'color' : 'red'
		});
	}
	var go_pos = $text.search(/����/i);
	var go_txt = $text.substr(go_pos, 4);
	if(go_txt === '����') {
		var t = $(this).text();
		t = t.replace(go_txt, '<span class="gold_black">����</span>');
		$(this).html(t);
	}
});

Revision: 57476
at May 28, 2012 15:48 by StrawMan


Initial Code
//Colorize portions of string.
$('div.tr_history_use_sub_div').each(function() {
	var $text = $(this).text();
	if($text.indexOf('+') >= 0) {
		$(this).css({
			'color' : 'green'
		});
	} else if($text.indexOf('-') >= 0) {
		$(this).css({
			'color' : 'red'
		});
	}
	var go_pos = $text.search(/ゴールド/i);
	var go_txt = $text.substr(go_pos, 4);
	if(go_txt === 'ゴールド') {
		var t = $(this).text();
		t = t.replace(go_txt, '<span class="gold_black">ゴールド</span>');
		$(this).html(t);
	}
});

Initial URL

                                

Initial Description
Colorize Portions Of String

Initial Title
Colorize Portions Of String

Initial Tags
jquery

Initial Language
jQuery