简体   繁体   中英

Week Picker CSS

The date picker we are using does not have week picker feature we need. I wonder if we can fake a week picker through CSS since the only day users can choose is Saturday.

I cannot just simply target and highlight a row because of the server-generated code looks like below:

<tr>
  <td>1</td>
  <td>2</td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  <td>8</td>
  <td>9</td>
  <td>10</td>
  <td>11</td>
  <td>12</td>
  <td>13</td>
</tr>
<tr>
  <td>14</td>
  <td>15</td>
  <td>16</td>
  <td>17</td>
  <td>18</td>
  <td>19</td>
  <td>20</td>
  <td>21</td>
  <td>22</td>
  <td>23</td>
  <td>24</td>
  <td>25</td>
  <td>26</td>
</tr>
<tr>
  <td>27</td>
  <td>28</td>
  <td>29</td>
  <td>30</td>
  <td>31</td>
</tr>

Is it possible to write something like tr:focus:nth-child(6) to target the <tr> from n-6 to n, so I can highlight the whole week?

Thank you!

i don't think this can be do through css only. Hoping that this can fit the question, here is a fiddle that does it via jquery (although is only cosmetic highlight).

Here is my fiddle https://jsfiddle.net/too4svgm/1/

$("table td").click(function() {

 $tds = $(this).parent().parent().find("td");
  var a = $tds.index(this);
  var c = a - 6;
  $tds.css("background-color", "inherit");

  $tds.filter(function(index) {
    var b = (index <= a) && (index >= c);
    return b;
  }).css("background-color", "green");    

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM