dtxq82489 2011-07-07 11:07
浏览 42
已采纳

在jQuery datepicker中更改链接背景

i have a script. jQuery datepicker with url's on database.

<script>
    $(function() {
            $('#datepicker').datepicker({
                beforeShowDay: daysToMark,
                onSelect: function(date,evt){
                    if (evt.currentMonth < 10){
                        evt.currentMonth = "0"+evt.currentMonth;
                        }
                    if (evt.currentDay < 10){
                        evt.currentDay = "0"+evt.currentDay;
                        }
                        daysToMark(evt.currentYear+"-"+evt.currentMonth+"-"+evt.currentDay);
                        date.dpDiv.find('.ui-datepicker-current-day a')
                        .css('background-color', '#000000');
                        }
                });
        });

        <? 
        $dateArray = array();
        $sql = mysql_query("SELECT *
                            FROM module_news
                            "); 
                while ($row = mysql_fetch_array($sql)) {
                    array_push($dateArray,$row["tarigi"]);
                    }
        ?>
        var js_array = new Array();
        js_array = <?=json_encode($dateArray);?>;
        var dates = js_array;
        function daysToMark(evt) {
            if($.inArray(evt, js_array) != -1 )
            {

                window.open("index.php?action=news_archive&date="+evt+"&lang=<?=$lang?>", "_self");
            }
        return [true, "", ""];
        }
       </script>

I have database date links in array, and i want to highlight links, so when i write news at 2011-07-08 on my calendar it 'll be linked but not highlighted, how can i change background color of linked dates?

thanks

  • 写回答

2条回答 默认 最新

  • dongmu3187 2011-07-07 11:40
    关注

    In the daysToMark method you return return [true, "", ""]; as required by the beforeShowDay event.

    The second position in that array hold a class that will be applied to the data. So if you add a class there return [true, "linked", ""]; and in you css code set a rule of

    .linked .ui-state-default{
      background-color:red;
      background-image:none; /*this in case the them you use uses background images*/
    }
    

    it should do what you want..

    demo at http://jsfiddle.net/gaby/S79fa/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算