2013-12-16 45 views
0

我做了一些控件,它可以編輯加載到應用程序中的特定頁面的背景顏色,字體等。執行1格的JQuery函數

enter image description here

現在,當我改變,例如,背景顏色,整個頁面獲取顏色。

當然,我不希望我的控制面板(左側和右側)也改變。

整個頁面被構建爲一個html表格,在中間的列中,是一個div,它是我想要編輯的頁面。

中間的div代碼:

<td style = " vertical-align:top" ><% if (Model != null && Model.PublicationID != 0) 
     { 
      Html.RenderPartial("TopBar", Model); %> 
    <div class="xcontainer"> 

     <% foreach (QuartzNew.Models.Edition e in Model.Editions) 
      { 
       if (e != null) 
       { 
        Model.SelectedEdition = e; 
        Html.RenderPartial("GridCell", Model); // If SingleIssueShopLayout="Grid" else Html.RenderPartial("SearchResult", Model); 
       } 
      } 
     %> 
     <% } %> 
    </div> 
    </td> 

Jquery的功能,我想執行:

   $('#page-properties-BGcolor-Colorpicker').miniColors({ 
        change: function (hex) { 
         $('#page-properties-BGcolor-Colorpicker').val(hex) 
         $("html, body").not($(".Controlpanel")).css("background", hex); 
         //     fillPageValues() 
        } 
       }); 
+0

難道你不能直接向中間的元素?你可以在jsfiddle上顯示一個例子嗎?您必須使用表格進行格式設置,可能難以設計風格 –

回答

0

您是否嘗試過簡單地改變:

$("html, body").not($(".Controlpanel")).css("background", hex);

$(".xcontainer").css("background", hex);

目前您的參數範圍可能不夠具體,不足以簡單地隔離您希望定位的元素。

0

您選擇檢索htmlbody元件,其不$(".Controlpanel")這是一個有點無厘頭,因爲這總是如此,將改變HTML和身體的背景。

你必須選擇你想改變的元素,而不是HTML的正文。試試這個:

$('.xcontainer').css("background", hex);