미채택 완료

오늘 요일칸에 색상넣기

2017-11-26 (일) 18:02:40 2,114

위그림처럼 table로 된 월~일 까지 요일이있습니다.

아래그림처럼 오늘 요일에 해당하는 칸에 색상을 넣었으면합니다.

오늘이 금요일이면 금요일 칸에 빨간색으로 표시되는 방법 좀 알려주세요!!

고수님들 부탁드립니다.

DalCode  님이 아래처럼 답 달아주셨는데 잘 안되네요 혹시 뭐가 빠진거나 수정해애될 부분있는 지 봐주시면 감사하겠습니다.

<table>   <tr>     <th>일</th><th>월</th><th>화</th><th>수</th><th>목</th><th>금</th><th>토</th>   </tr> </table>   <script> var today = new Date(); var yoil = today.getDay(); $('table th').eq(yoil).attr('style', 'background-color:red; color:white'); </script>

|

답변 2개

혹 내용에 다른 테이블이 있을수 있습니다 

id를 지정해 보세요 

<table id="week_table">   <tr>     <th>일</th><th>월</th><th>화</th><th>수</th><th>목</th><th>금</th><th>토</th>   </tr> </table>   <script> var today = new Date(); var yoil = today.getDay(); $('#week_table th').eq(yoil).attr('style', 'background-color:red; color:white'); </script>

소스에 사용하신

Date.getToday ()가 넘겨주는 값을 잘 판단해보시고

jquery로 접근하는 값과 일치하는지를 판단하면 됩니다

참고로 

getToday ()

https://msdn.microsoft.com/ko-kr/library/5wtd2bt8(v=vs.94).aspx

답변을 작성하려면 로그인이 필요합니다.