如何算法颜色相反的对角线表的对角线 [英] How to algorithmically color the opposite diagonal of a table's diagonal

查看:224
本文介绍了如何算法颜色相反的对角线表的对角线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的彩色形成对角线框的表。

I have a table that I colored boxes that form the diagonal.

我要寻找如何着色算法相反的对角线。

I am looking how to color algorithmically the opposite diagonal.

演示: http://jsfiddle.net/pJt7x/

Javascript的(1 == 2必须更换)

Javascript (1 == 2 must be replaced) :

for (i=0; i<=5; i++) {
    $('table').append('<tr>');

    for (j=0; j<=5; j++)
        ((i == j)||(1 == 2)) ?
            $('tr:last').append('<td class="x"></td>') : 
                $('tr:last').append('<td></td>');

    $('table').append('</tr>'); 
}

答: http://jsfiddle.net/pJt7x/2/

推荐答案

相反的对角线 I + J == 5

这篇关于如何算法颜色相反的对角线表的对角线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆