IE8:element:first-child deosn't工作(选择我真正想要的父级)

发布于 2024-12-08 05:47:37 字数 620 浏览 2 评论 0原文

适用于 chrome,不适用于 ie8: http://jsfiddle.net/a7rXZ/2/

所以,当当您单击“接受”、“拒绝”或“打开”时,它会更改小单击菜单旁边的文本(同时保持左侧文本的样式(这是理想的))。但在 IE 中,它似乎正在替换父元素(因为文本的样式不保持不变)

关于如何让它在 IE8 中表现的任何想法?

这是有问题的代码:

$j('.change_option').click(function() {
    $j('#change_status_menu').fadeToggle("fast");
    $j(".status .status_header span:first-child").attr("class", $j(this).html());
    $j(".status .status_header span:first-child").html($j(this).html());
    $j('#proposal_status').val($j(this).attr("name"));
    unsaved_changes = true;
});

Works in chrome, not ie8: http://jsfiddle.net/a7rXZ/2/

so, when you click on accepted, decline, or open, it changes the text adjacent to the little click menu (while maintaining styling of the text on the left (this is ideal)). but in IE, it seems to be replacing the parent element (cause the styling of the text doesn't remain the same)

any ideas for how to get this to behave in IE8?

this is the code in question:

$j('.change_option').click(function() {
    $j('#change_status_menu').fadeToggle("fast");
    $j(".status .status_header span:first-child").attr("class", $j(this).html());
    $j(".status .status_header span:first-child").html($j(this).html());
    $j('#proposal_status').val($j(this).attr("name"));
    unsaved_changes = true;
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缱倦旧时光 2024-12-15 05:47:37

我怀疑 IE 只是在 class 属性中的标记有问题。我不会责怪 IE,因为它完全无效。解决方案实际上是使标记更清晰,并仅将文本/标记的相关部分从选项复制到状态标题

我已经清理了一些标记并重新设计了 jQuery,以仅选择操作 status-header 所需的 text()class 元素。基本上,我已将选项转换为无序列表,而不是使用

的组合。因此,这可能不完全是您想要的,因为我不确定您是否可以更改标记,并且我还删除了 .badge 类。

问题主要在于 JavaScript 将 HTML 内容添加到 .status-header span 元素的 class 属性中,而且示例中的许多文本位于任何元素之外,因此 JavaScript实际上每次选择的内容太多了。我看到的另一个问题是,您已经复制了辅助状态标题的标记,因此不必每次都替换此 HTML,而是更容易提取一个类(“打开”、“已接受”或“已拒绝”)和选项文本。

可以做更多事情来简化代码,例如复制到标头的 .classtext() 现在完全相同,因此应该进行简化。

这是一个在 Chrome 和 IE8 中为我工作的 演示

为了完整起见,请在此处是所有代码:

HTML

<div class="proposal_status">
    <div id="change_status_menu" style="">
        <div class="change_status_menu">
            <ul class="container">
                <li class="Open" name="1">Open</li>
                <li class="Accepted" name="2">Accepted</li>
                <li class="Declined" name="3">Declined</li>
            </ul>
        </div>
        <div class="arrow_border_2"></div>
        <div class="arrow_border"></div>
        <div class="arrow"></div>
    </div>

    <input id="proposal_status" name="proposal[status]" type="hidden" value="2">
    <div class="status">
        <div class="status_header">
            <span class="Accepted">Accepted</span>
            <div class="action_button change_status">Change Status</div>
        </div>
        <div class="info">
            <div class="prop-status-details">
                Accepted by 
                <strong>aoei eui</strong> from 
                <strong>127.0.0.1</strong>
            </div>
        </div>
    </div>
</div>

JavaScript

$j = jQuery.noConflict();

$j(function() {
    $j(".change_status").click(function() {
        $j('#change_status_menu').fadeToggle("fast");
    });
    $j('li').click(function() {
        $j('#change_status_menu').fadeToggle("fast");
        $j(".status .status_header span").attr("class", $j(this).attr('class'));
        $j(".status .status_header span").html($j(this).text());
        $j('#proposal_status').val($j(this).attr("name"));
        unsaved_changes = true;
    });
});

CSS

.no_padding{
    padding: 0px !important;
}
.properties-shell {
    background: #f3f3f3;
    width: 930px;
    position: relative;
    border-right: solid 10px #f3f3f3;
    border-left: solid 10px #f3f3f3;

}
.properties-shell-top {
    margin-top: 15px;
    background: url(../images/bucket_wide_bg.gif) no-repeat;
    width: 950px;
    height: 10px;
    overflow: hidden;
}
.properties-shell-bottom {
    background: url(../images/bucket_wide_bg.gif) 0 -10px no-repeat;
    width: 950px;
    height: 10px;
    overflow: hidden;
}
.properties-main {
    background: #FFF;
    display: table;
    border-left: solid 1px #e5e5e5;

}
.properties_header{
    border-right: solid 1px #e5e5e5;

    display: block;
    height: 38px;
    border-top: rgb(229,229,229);
    background: #e5e5e5;
    background: -webkit-gradient(linear, left bottom, left top, 
        color-stop(0%,#e5e5e5), 
        color-stop(96%,#f2f2f2), 
        color-stop(97%,#ffffff), 
        color-stop(98%,#e5e5e5)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Opera11.10+ */
    background: -ms-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* W3C */
}
.properties_first_col{        
    padding: 20px;
    width: 415px;
    float: left;
    display: inline-block;
}
.properties_second_col{
    padding: 20px;
    padding-right: 15px;
    width: 210px;
    float: left;
    display: inline-block;
}
.properties_options{
    background: #F7F7F7;
    float: right;
    padding: 20px;
    width: 187px;
    border-left: solid 1px #e1e1e1;
    border-right: solid 1px #e1e1e1;
    border-bottom: solid 1px #e1e1e1;
    min-height: 268px;
}

.option_select{
    padding: 5px;
    padding-top: 0px;
    padding-bottom: 10px;
    font-size: 13px;
    color: #747474;
}

.proposal_status {
    position: absolute;
    top: 266px;
    right: 0px;
    margin-right: 1px;
}
.change_status_menu {
    border-radius: 5px;
    background: rgba(235,235,235, 0.95);
    border: 1px solid #d3d3d3;
    width: 142px;
    height: 110px;
    position: absolute;
    z-index: 1000;
    right: 10px;
    bottom: 77px;
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0px 2px 2px rgba(0,0,0,0.1);

}
.change_status_menu .container{
    border: 1px solid white;
    padding: 5px;
    border-radius: 4px;
}
.change_status_menu .container li {
    display: block;
    width: 120px;
    padding:5px 0 5px 10px;
    margin:0;             
}

.change_status_menu .container li:hover{
    background: -webkit-linear-gradient(top, #ffffff 2%, #e9e9e9 96%, #F3F3F3 85%, #e9e9e9 96%, #ffffff 98%); /* Chrome10+,Safari5.1+ */
    border: 1px solid #d7d7d7;
    border-radius: 3px;
    padding-top: 4px;
    padding-bottom: 4px;
    padding-left: 9px;
}
.arrow {
    z-index: 1003;
    border-color: #EDEDED transparent transparent transparent;
    border-style: solid;
    border-width: 10px;
    height:0;
    width:0;
    position:absolute;
    right: 38px;
    bottom: 60px;
}
.arrow_border {
    z-index: 1001;
    border-color: #d3d3d3 transparent transparent transparent;
    border-style: solid;
    border-width: 10px;
    height:0;
    width:0;
    position:absolute;
    right: 38px;
    bottom: 58px;
}
.arrow_border_2 {
    z-index: 1002;
    border-color: #fff transparent transparent transparent;
    border-style: solid;
    border-width: 10px;
    height:0;
    width:0;
    position:absolute;
    right: 38px;
    bottom: 59px;
}
.proposal_status .status{
    width: 227px;
}
.proposal_status .status .status_header,
.proposal_status .status .Unpublished{
    background: #e5e5e5;
    background: -webkit-gradient(linear, left bottom, left top, 
        color-stop(0%,#e5e5e5), 
        color-stop(96%,#f2f2f2), 
        color-stop(97%,#ffffff), 
        color-stop(98%,#e5e5e5)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Opera11.10+ */
    background: -ms-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* W3C */

    width: 227px;
    height: 30px;
}
.proposal_status .status .status_header .change_status{
    width: 88px;
    font-size: 9px;
    float: right;
    display: inline-block;
    margin: 5px;
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
}
.proposal_status .Accepted,
.proposal_status .Declined,
.proposal_status .Open{
    margin: 5px;
    display: inline-block;
    text-transform: uppercase;
    font-size: 14px;
    color: #848484 !important;
    text-shadow:#fff 0px 1px 0, #fff 0 -1px 0;                    
}
.proposal_status .Accepted .badge,
.proposal_status .Declined .badge,
.proposal_status .Open .badge,
.proposal_status .Unpublished .badge{

    width: 17px;
    height: 17px;
    display: inline-block;
    position: relative;
    top: 3px;
}
.proposal_status .Accepted .badge{
    background: url(/images/header_status_green.png) no-repeat;
}

.proposal_status .Declined .badge{
    background: url(/images/header_status_blue.png) no-repeat;
}

.proposal_status .Open .badge{
    background: url(/images/header_status_grey.png) no-repeat;
}

.proposal_status .Unpublished .badge{
    background: url(/images/header_status_white.png) no-repeat;
}

.proposal_status .status .info{
    background: #F2F2F2;
    background: -webkit-gradient(linear, left bottom, left top, 
        color-stop(0%,#F2F2F2), 
        color-stop(100%,#D6D6D6)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* Opera11.10+ */
    background: -ms-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F2F2F2', endColorstr='#D6D6D6',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* W3C */
    box-shadow: inner 0 2px 2px #bbb;
    -moz-box-shadow: inset 0 2px 2px #bbb;
    -webkit-box-shadow: inset 0 2px 2px rgba(0,0,0,0.2);
}

.prop-status-details {
    padding: 10px;
    color: #5F5F5F;
    line-height: 15px;
}
.proposal_status .status .Unpublished{
    margin-top: 95px;
    text-transform: uppercase;
    text-indent: 10px;
    line-height: 30px;
    font-size: 14px;
    color: #818181;
    text-shadow:#fff 0px 1px 0, #fff 0 -1px 0;
    box-shadow: none;
}

.action_button {
    font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif;
    background: #FCFCFC;
    border: 1px solid #DCDCDC;
    border-radius: 4px;
    padding-left: 5px;
    padding-right: 5px;
    font-size: 10px;
    line-height: 18px;
    color: #8B8B8B !important; 
    text-transform:uppercase !important;
    /*    text-shadow: #555 0px -1px 1px;*/
    /*    letter-spacing:1px;*/


    font-size: 11px;
    font-weight: bold;
    line-height: 18px;

}
.action_button:hover{
    text-decoration: none;
    background: #f4f4f4;
    border: 1px solid #ccc;
}

I suspect IE just has a problem with mark-up in class attributes. I wouldn't blame IE though since it's totally invalid. The solution is really a case of making the mark-up cleaner and copying only the relevant sections of text/mark-up from the options to the status header.

I've cleaned up the mark-up a little and re-worked the jQuery to select only the text() and class necessary for manipulating the status-header element. Basically, I've turned the options into an unordered list, rather than using a combination of <div> and <span>. So it might not be exactly what you are after, since I am not sure if you can change the mark-up and I have also removed the the .badge class.

The problems were mainly that the JavaScript was adding HTML content into the class attribute of the .status-header span element, but also a lot of the text in the example was outside any element, so the JavaScript was actually selecting too much content each time. The other problem I could see was that you had already duplicated the mark-up for the secondary status heading, so rather than replacing this HTML each time, it was easier to just extract the one class ('Open', 'Accepted' or 'Declined') and the text of the option.

There is more that can be done to simplify the code, for example the .class and text() being copied to the header are now exactly the same so should be simplified.

Here is a demo which is working for me in Chrome and IE8

For completeness, here is all the code:

HTML

<div class="proposal_status">
    <div id="change_status_menu" style="">
        <div class="change_status_menu">
            <ul class="container">
                <li class="Open" name="1">Open</li>
                <li class="Accepted" name="2">Accepted</li>
                <li class="Declined" name="3">Declined</li>
            </ul>
        </div>
        <div class="arrow_border_2"></div>
        <div class="arrow_border"></div>
        <div class="arrow"></div>
    </div>

    <input id="proposal_status" name="proposal[status]" type="hidden" value="2">
    <div class="status">
        <div class="status_header">
            <span class="Accepted">Accepted</span>
            <div class="action_button change_status">Change Status</div>
        </div>
        <div class="info">
            <div class="prop-status-details">
                Accepted by 
                <strong>aoei eui</strong> from 
                <strong>127.0.0.1</strong>
            </div>
        </div>
    </div>
</div>

JavaScript

$j = jQuery.noConflict();

$j(function() {
    $j(".change_status").click(function() {
        $j('#change_status_menu').fadeToggle("fast");
    });
    $j('li').click(function() {
        $j('#change_status_menu').fadeToggle("fast");
        $j(".status .status_header span").attr("class", $j(this).attr('class'));
        $j(".status .status_header span").html($j(this).text());
        $j('#proposal_status').val($j(this).attr("name"));
        unsaved_changes = true;
    });
});

CSS

.no_padding{
    padding: 0px !important;
}
.properties-shell {
    background: #f3f3f3;
    width: 930px;
    position: relative;
    border-right: solid 10px #f3f3f3;
    border-left: solid 10px #f3f3f3;

}
.properties-shell-top {
    margin-top: 15px;
    background: url(../images/bucket_wide_bg.gif) no-repeat;
    width: 950px;
    height: 10px;
    overflow: hidden;
}
.properties-shell-bottom {
    background: url(../images/bucket_wide_bg.gif) 0 -10px no-repeat;
    width: 950px;
    height: 10px;
    overflow: hidden;
}
.properties-main {
    background: #FFF;
    display: table;
    border-left: solid 1px #e5e5e5;

}
.properties_header{
    border-right: solid 1px #e5e5e5;

    display: block;
    height: 38px;
    border-top: rgb(229,229,229);
    background: #e5e5e5;
    background: -webkit-gradient(linear, left bottom, left top, 
        color-stop(0%,#e5e5e5), 
        color-stop(96%,#f2f2f2), 
        color-stop(97%,#ffffff), 
        color-stop(98%,#e5e5e5)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Opera11.10+ */
    background: -ms-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* W3C */
}
.properties_first_col{        
    padding: 20px;
    width: 415px;
    float: left;
    display: inline-block;
}
.properties_second_col{
    padding: 20px;
    padding-right: 15px;
    width: 210px;
    float: left;
    display: inline-block;
}
.properties_options{
    background: #F7F7F7;
    float: right;
    padding: 20px;
    width: 187px;
    border-left: solid 1px #e1e1e1;
    border-right: solid 1px #e1e1e1;
    border-bottom: solid 1px #e1e1e1;
    min-height: 268px;
}

.option_select{
    padding: 5px;
    padding-top: 0px;
    padding-bottom: 10px;
    font-size: 13px;
    color: #747474;
}

.proposal_status {
    position: absolute;
    top: 266px;
    right: 0px;
    margin-right: 1px;
}
.change_status_menu {
    border-radius: 5px;
    background: rgba(235,235,235, 0.95);
    border: 1px solid #d3d3d3;
    width: 142px;
    height: 110px;
    position: absolute;
    z-index: 1000;
    right: 10px;
    bottom: 77px;
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0px 2px 2px rgba(0,0,0,0.1);

}
.change_status_menu .container{
    border: 1px solid white;
    padding: 5px;
    border-radius: 4px;
}
.change_status_menu .container li {
    display: block;
    width: 120px;
    padding:5px 0 5px 10px;
    margin:0;             
}

.change_status_menu .container li:hover{
    background: -webkit-linear-gradient(top, #ffffff 2%, #e9e9e9 96%, #F3F3F3 85%, #e9e9e9 96%, #ffffff 98%); /* Chrome10+,Safari5.1+ */
    border: 1px solid #d7d7d7;
    border-radius: 3px;
    padding-top: 4px;
    padding-bottom: 4px;
    padding-left: 9px;
}
.arrow {
    z-index: 1003;
    border-color: #EDEDED transparent transparent transparent;
    border-style: solid;
    border-width: 10px;
    height:0;
    width:0;
    position:absolute;
    right: 38px;
    bottom: 60px;
}
.arrow_border {
    z-index: 1001;
    border-color: #d3d3d3 transparent transparent transparent;
    border-style: solid;
    border-width: 10px;
    height:0;
    width:0;
    position:absolute;
    right: 38px;
    bottom: 58px;
}
.arrow_border_2 {
    z-index: 1002;
    border-color: #fff transparent transparent transparent;
    border-style: solid;
    border-width: 10px;
    height:0;
    width:0;
    position:absolute;
    right: 38px;
    bottom: 59px;
}
.proposal_status .status{
    width: 227px;
}
.proposal_status .status .status_header,
.proposal_status .status .Unpublished{
    background: #e5e5e5;
    background: -webkit-gradient(linear, left bottom, left top, 
        color-stop(0%,#e5e5e5), 
        color-stop(96%,#f2f2f2), 
        color-stop(97%,#ffffff), 
        color-stop(98%,#e5e5e5)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Opera11.10+ */
    background: -ms-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* W3C */

    width: 227px;
    height: 30px;
}
.proposal_status .status .status_header .change_status{
    width: 88px;
    font-size: 9px;
    float: right;
    display: inline-block;
    margin: 5px;
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
}
.proposal_status .Accepted,
.proposal_status .Declined,
.proposal_status .Open{
    margin: 5px;
    display: inline-block;
    text-transform: uppercase;
    font-size: 14px;
    color: #848484 !important;
    text-shadow:#fff 0px 1px 0, #fff 0 -1px 0;                    
}
.proposal_status .Accepted .badge,
.proposal_status .Declined .badge,
.proposal_status .Open .badge,
.proposal_status .Unpublished .badge{

    width: 17px;
    height: 17px;
    display: inline-block;
    position: relative;
    top: 3px;
}
.proposal_status .Accepted .badge{
    background: url(/images/header_status_green.png) no-repeat;
}

.proposal_status .Declined .badge{
    background: url(/images/header_status_blue.png) no-repeat;
}

.proposal_status .Open .badge{
    background: url(/images/header_status_grey.png) no-repeat;
}

.proposal_status .Unpublished .badge{
    background: url(/images/header_status_white.png) no-repeat;
}

.proposal_status .status .info{
    background: #F2F2F2;
    background: -webkit-gradient(linear, left bottom, left top, 
        color-stop(0%,#F2F2F2), 
        color-stop(100%,#D6D6D6)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* Opera11.10+ */
    background: -ms-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F2F2F2', endColorstr='#D6D6D6',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* W3C */
    box-shadow: inner 0 2px 2px #bbb;
    -moz-box-shadow: inset 0 2px 2px #bbb;
    -webkit-box-shadow: inset 0 2px 2px rgba(0,0,0,0.2);
}

.prop-status-details {
    padding: 10px;
    color: #5F5F5F;
    line-height: 15px;
}
.proposal_status .status .Unpublished{
    margin-top: 95px;
    text-transform: uppercase;
    text-indent: 10px;
    line-height: 30px;
    font-size: 14px;
    color: #818181;
    text-shadow:#fff 0px 1px 0, #fff 0 -1px 0;
    box-shadow: none;
}

.action_button {
    font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif;
    background: #FCFCFC;
    border: 1px solid #DCDCDC;
    border-radius: 4px;
    padding-left: 5px;
    padding-right: 5px;
    font-size: 10px;
    line-height: 18px;
    color: #8B8B8B !important; 
    text-transform:uppercase !important;
    /*    text-shadow: #555 0px -1px 1px;*/
    /*    letter-spacing:1px;*/


    font-size: 11px;
    font-weight: bold;
    line-height: 18px;

}
.action_button:hover{
    text-decoration: none;
    background: #f4f4f4;
    border: 1px solid #ccc;
}
魂ガ小子 2024-12-15 05:47:37

问题是您正在使用 html 内容设置 class 属性。我已经完成了一个快速解决方法:

http://jsfiddle.net/a7rXZ/4/

只需更改.html().text()。原始返回的值如下所示(是的,包括所有空格):

                <div class="badge"></div>
                Declined

但您期望的只是文本 Declined,新版本可以检索该文本。您可能想考虑一种稍微更强的策略(删除空格是一个开始,但我指的是更严格的东西),尽管现在新版本有效。

The problem is that you're setting the class attribute with html content. I've done a quick workaround:

http://jsfiddle.net/a7rXZ/4/

Simply changing .html() with .text(). The original returns a value that looks like the following (yes, including all the whitespace):

                <div class="badge"></div>
                Declined

But you're expecting just the text Declined, which is retrievable by the new version. You might like to consider a slightly stronger tactic (whitespace removal would be a start, but I'm referring to something more rigid), even though for now the new version works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文