JSFiddle - React, Tailwind, and code Playground

by kuonyuu

HTML

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<li class="selectedTagItem"><span class="fa fa-tags"></span> 土地
    <input name="tags_3_1[]" value="78285" type="hidden"> <span class="fa fa-times" title="移除此Tag"></span><span class="fa fa-plus float_right" title="Add subTag"></span>
    <div class="subTag">
        <ul class="selectedTagSub"></ul>
        <input type="text" class="tag">
        <ul class="autoListSub"></ul>
    </div>
</li>

SCSS

.float_right {
    float: right;
}

.selectedTagItem, .tagItem {
    border: none;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    background-color: #1f8dd6;
    color: #fff;
    display: inline-block;
    vertical-align: top;
    padding: 3px 6px;
    margin: 3px 4px 3px 0px;
    cursor: pointer;
    line-height: 16px;
    font-size: 12px;
    font-weight: normal;
    .fa-tags {
        margin-right: 3px;
    }
    &:hover {
        .opacity(0.75);
    }
}
.selectedTagItem {
    vertical-align: top;
    input[type="text"].tag {
        width: auto;
        margin-bottom: 0;
        display: none;
    }
    &.addTag {
        input[type="text"].tag {
            display: block;
        }
    }
    .fa-plus.float_right { margin-top: 2.5px; margin-left: 8px; color: rgb(157, 255, 67); }
}
ul {
    margin: 0;
    padding: 0;
}
input {
    margin: 0 1px;
    padding: 0 2px;
    display: inline-block;
    border-radius: 3px 3px 3px 3px;
    -moz-border-radius: 3px 3px 3px 3px;
    -webkit-border-radius: 3px 3px 3px 3px;
    vertical-align: middle;
    line-height: 16px;
    height: 16px;
    width: 28px;
    border: 1px solid #999;
    background-color: #fff;
    outline: none;
    color: #444;
    font-size: 12px;
    

}

JavaScript

$(".selectedTagItem .fa-plus").click ( function() {
    $(this).parents(".selectedTagItem").toggleClass("addTag");
});