首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >函数this.text=text;到html

函数this.text=text;到html
EN

Stack Overflow用户
提问于 2012-12-18 01:43:58
回答 1查看 135关注 0票数 0

我有一些日历中的tootlip代码。我希望能够在工具提示中显示html,这可能吗?每次我尝试将其更改为接受html时,它都会崩溃,它现在只允许文本,我不知道如何更改它以允许使用html

代码语言:javascript
复制
        <!DOCTYPE html>
        <html>
        <head>
          <meta http-equiv="content-type" content="text/html; charset=UTF-8">
          <title></title>

          <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.2.js'></script>

          <link rel="stylesheet" type="text/css" href="/css/normalize.css">
          <link rel="stylesheet" type="text/css" href="/css/result-light.css">


              <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
              <script type='text/javascript' src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>


          <style type='text/css'>
            .pink > a {
            background-color: pink !important;
            background-image:none !important;
        }

        .green > a {
            background-color: green !important;
            background-image: none !important;
        }

          </style>



        <script type='text/javascript'>//<![CDATA[
        $(window).load(function(){
        var Event = function(text, className) {
            // would like to convert this to allow for html
            this.text = text;
            // this.html = text; // does not work
            this.className = className;
        };

        var events = {};
        events[new Date("01/01/2013")] = new Event("New Years Day", "pink");
        events[new Date("12/25/2012")] = new Event("<B>Merry</b> Christmas", "green");

        console.dir(events);

        $("#dates").datepicker({
            beforeShowDay: function(date) {
                var event = events[date];
                if (event) {
                    return [true, event.className, event.text];
                }
                else {
                    return [true, '', ''];
                }
            }
        });
        });//]]>

        </script>


        </head>
        <body>
          <div id="dates"></div>


        </body>


        </html>

预先感谢您提供的任何代码或帮助

约翰尼

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-18 02:34:28

title属性不允许html代码。

但是有几个框架可以让你修改悬停。

我使用了jQuery Tooltip

代码语言:javascript
复制
<script src="http://jquery.bassistance.de/tooltip/jquery.tooltip.js"></script>
$('*').tooltip();

在这里,您将看到工具提示已被修改,并且粗体已就位。

http://jsfiddle.net/Morlock0821/WqrMK/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13919236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档