0

div テキストを動的に入力しています。テキストの内容に応じてテキストの色を変えたい。

これが私のjsです-

var BillView = Backbone.View.extend({

template:_.template($('#bill-view-template').text()),

tagname: 'div',

className: 'billView',

initialize: function(options){
    this.options = options;
    $('.ViewD').append(this.$el);

    if($('.vote').val('') === 'Yea' || 'Aye'){
        $('.vote').css('color', 'green');
    } else if($('.vote').val('') === 'Nay' || 'No'){
        $('.vote').css('color', 'red');
    }

    this.render();
},

render: function(){
    this.$el.append(this.template({options: this.model}));
},

}))

<script type="text/template" id="bill-view-template">
        <div class='created'><%= options.get('created')%></div>
        <div class='bill'><%= options.get('vote').question %></div>
        <div class='vote'><%= options.get('option').value %></div>
    </script>

一度に 5 つのオブジェクトしか呼び出していません。値に関係なく、最初の 4 が緑に変わります。5番目は全く変わりません。

助けてください

4

1 に答える 1