最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Set a span visible and invisible - Stack Overflow

programmeradmin6浏览0评论

I have a span that is part of a JSON object and need to set it visible or invisible due to some config options.

I have the following code but I am struggling to make it work:

function isc_getsvldata() {

        return JSON.stringify(
            {

                polygon_shading_template_hash:
                {
                    AVAILABLE_3_NONE:
                    {
                        interior: 0x<%= System.Drawing.ColorTranslator.ToHtml(Config.ColourSoldout).TrimStart('#') %>,
                        border: 0x<%= System.Drawing.ColorTranslator.ToHtml(Config.ColourSoldout).TrimStart('#') %>,
                        poly_tool_tip_template:

                             <%= Config.ISCavailability ?"<br><span class='textBlack'> [% @1:((polygon.counters[1] * 100) / polygon.counters[0]); %]%</span>":"<span class='someotherclass'>Nothing</span>"%>
                    }
                }
            }
        );
}

I have a span that is part of a JSON object and need to set it visible or invisible due to some config options.

I have the following code but I am struggling to make it work:

function isc_getsvldata() {

        return JSON.stringify(
            {

                polygon_shading_template_hash:
                {
                    AVAILABLE_3_NONE:
                    {
                        interior: 0x<%= System.Drawing.ColorTranslator.ToHtml(Config.ColourSoldout).TrimStart('#') %>,
                        border: 0x<%= System.Drawing.ColorTranslator.ToHtml(Config.ColourSoldout).TrimStart('#') %>,
                        poly_tool_tip_template:

                             <%= Config.ISCavailability ?"<br><span class='textBlack'> [% @1:((polygon.counters[1] * 100) / polygon.counters[0]); %]%</span>":"<span class='someotherclass'>Nothing</span>"%>
                    }
                }
            }
        );
}
Share Improve this question edited Nov 7, 2022 at 12:35 gouessej 4,0754 gold badges38 silver badges74 bronze badges asked Feb 16, 2012 at 11:48 Jack MJack M 2,5744 gold badges30 silver badges52 bronze badges 3
  • 3 Ha? What does that code mean? – gdoron Commented Feb 16, 2012 at 11:50
  • That is a code that return a text message depending on the availability(ISCavailability) flag being set to true or false. – Jack M Commented Feb 16, 2012 at 15:19
  • I added and asp tags, because I assume you're working with those... – weltraumpirat Commented Feb 16, 2012 at 21:36
Add a ment  | 

1 Answer 1

Reset to default 13

I am not sure what Config.ISCavailability does, but what you should not use the visible property. The end result you want is most likely something like either <span style="display: none"> or <span style="visibility: hidden">.

The correcsponding displayed tags would then be <span style="display: block"> and <span style="visibility: visible">.

If Config.ISCavailability is a boolean, then I think you want something like this:

<span class="textBlack" style="visibility:<%= Config.ISCavailability ? "visible" : "hidden" %>">

发布评论

评论列表(0)

  1. 暂无评论