1、这里关键是对页面中的传值,其次是动态的创建一个数组,用来存值
$(val).css("background-color", "rgb(251, 248, 233)");//取消选中
var ary;
if (crival_number.indexOf(fnumber) > 0) {
var fnumbers = crival_number.split(",");
//然后做的操作便是从crival_number中去掉相对应的number
ary = new Array(fnumbers.length);
for (var i = 0, j = 0; i < fnumbers.length; i++, j++) {
if (fnumbers[i] != fnumber) {
ary[j] = fnumbers[i];
}
}
}
var str = "";
if (ary.length > 0) {
for (var i = 0; i < ary.length; i++) {
if (ary[i] != "" && ary[i] != undefined)
str = str + "," + ary[i];
}
}
parent.document.getElementById('crival_number').value = str;
2、初次加载的过程中对table中的每一个tr的颜色的设置,而设置的条件是tr的自定义的fnumber属性
var str;
var fnumbers = parent.document.getElementById('crival_number').value;
$('tr').each(function () {
//str = str + $(this).attr('fnumber') + ",";
if (fnumbers.indexOf($(this).attr('fnumber')) > 0) {
$(this).css('background-color', 'rgb(246, 184, 197)')
}
});
3、另外父页面的获取的方法获取的方式是不同的,这要根据具体情况来定
4、注意颜色的设置过程中rgb(255,255,255),的使用方法,在属性设置的时候加上引号,作为字符串来进行处理