-2

サイドナビゲーションのリンクの特定のdivonclickを強調表示しようとしています。これまでのところ(デフォルトページの場合)機能しますが、別のページに移動してサイドナビゲーションの項目をクリックすると、指定したdivに固定されますが、強調表示されません。リンクを強調表示するには、リンクを再度クリックする必要があります。

var App = {
    SetBaseLine: function() {
    jQuery("#priceRange, #satisfaction").removeClass("activeListColor");
    }
};

jQuery(document).ready(function() {
    jQuery('a#priceLink').click(function(e) {
        App.SetBaseLine();
        jQuery('#priceRange').addClass('activeListColor');
    });
    jQuery('a#satisfactionLink').click(function(e) {
        App.SetBaseLine();
        jQuery('#satisfaction').addClass('activeListColor');
    });


    <div id="priceRange">
            <div class="header">Price Range<br /><a id="button1" href="javascript:toggle3('colcontent1','button1');" ><img src="images/more-info-button.png" width="76" height="20" /></a></div>
            <div class="col2 topSpace">Packages  start at $29.99/month</div>
            <div class="col3"><span>Best Value</span><img src="images/red-trophy.png" class="trophy" /><br />Packages  start at $19.99/month</div>
            <div class="col4 topSpace">Packages  start at $29.99/month</div>
    </div> <!-- End of priceRange div -->

<div id="satisfaction">
         <div class="header">Customer Satisfaction <br /><a id="button2" href="javascript:toggle3('colcontent2','button2');" ><img src="images/more-info-button.png" width="76" height="20" /></a></div>
            <div class="col2 topSpace">American  Customer Satisfaction Index (ACSI) Rating: 68 </div>
            <div class="col3"><span>Most Popular</span><img src="images/red-trophy.png" class="trophy" /><br />American  Customer Satisfaction Index (ACSI) Rating: 71 </div>
            <div class="col4 topSpace">American  Customer Satisfaction Index (ACSI) Rating: 61 </div>
    </div> <!-- End of satisfaction div -->

助言がありますか??

4

1 に答える 1

0

ページを変更すると、DOMはハイライトクラスを削除および追加する準備ができていません。

したがって、グローバル変数を設定し、強調表示するリストアイテムをページにロードするたびに、その変数の値を確認し、対応するリストアイテムを強調表示してから、無効にします。

于 2012-06-07T21:16:43.167 に答える