当我的页面有超过4个网格时,如何在页面中设置4个网格样式? [英] How to style 4 grids in a page when my pages have more than 4 grids?

查看:82
本文介绍了当我的页面有超过4个网格时,如何在页面中设置4个网格样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页有6个网格,分别是grid1,grid2,grid3,grid4,grid5,grid6。当我点击搜索按钮时,我读取了grids中的数据。现在我想用grid1格式化grid1,grid2,grid4,grid5 `color:red`,我可以使用这些代码来设置它们:

#grid1.k-grid-content td {
color:red
}
#grid2.k-grid-content td {
color:red
}
#grid4.k-grid-content td {
color:红色
}
#grid5.k-grid-content td {
颜色:红色
}



我认为这种方式非常复杂和冗余,并且更改了这样的代码并单击搜索按钮,但是失败了。但是如果我首先搜索数据,然后执行更改代码,它就会成功。我发现我的更改代码失败了,因为起初我没有点击搜索按钮,网格没有任何数据(网格没有任何td颜色为红色)。如何更改我的代码?我只是做不想写复杂冗余的代码。可以和jqueryon事件一起使用吗?有人用on来设置网格td的样式吗?



 .GridColor {
color:red
}
$(function(){
$( #grid1.k-grid-content td)。addClass( GridColor);
$( #grid2.k-grid- content td)。addClass( GridColor);
$( #grid4.k-grid-content td)。addClass( GridColor);
$( #grid5.k-grid-content td)。addClass(< span class =code-string>
GridColor);
}

解决方案

(function(){


#grid1.k-grid-content td)。addClass( GridColor);


#grid2.k-grid-content td)。addClass( GridColor);

My pages have 6 grids called grid1,grid2,grid3,grid4,grid5,grid6.When I click the search button,I read the data in grids.now I want to style the grid1,grid2,grid4,grid5 with style `"color:red"`,I can style them using these codes:

#grid1.k-grid-content td {
color:red
}
#grid2.k-grid-content td {
color:red
}
#grid4.k-grid-content td {
color:red
}
#grid5.k-grid-content td {
color:red
}


I think this way is really complicated and redundant and change the codes like this and click the search button,but failed.But if I firstly seach data,and then execute the change code,it successed. I found that my changes codes failed because at first I have not clicked the "Search" button and the grid do not have any data(the grid have not any "td" to color red).How to change my code?I just do not want to write complicated and redundant codes.Can it be used with jquery "on" event?Anybody use "on" to style the grid td?

.GridColor {
      color:red
      }
        $(function () {
       $("#grid1.k-grid-content  td").addClass("GridColor");
       $("#grid2.k-grid-content  td").addClass("GridColor");
       $("#grid4.k-grid-content  td").addClass("GridColor");
       $("#grid5.k-grid-content  td").addClass("GridColor");
        }

解决方案

(function () {


("#grid1.k-grid-content td").addClass("GridColor");


("#grid2.k-grid-content td").addClass("GridColor");


这篇关于当我的页面有超过4个网格时,如何在页面中设置4个网格样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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