2012-04-18 59 views
0

我正在創建一個房間預訂系統。所以我想讓可選擇的那些td在哪裏取消選擇=「關閉」。請幫我做這個。我想只選那些td where unselectable =「off」

這是我的html代碼,這裏是我用來選擇它們的腳本。

<script> 
$(function() { 
    $("table").selectable(
    { 
     filter: 'tbody td unselectable:off ' 
    } 
    ); 
}); 
</script> 

但是什麼都沒有發生。 請幫我解決這個問題。

  <tr> 
       <td unselectable="on" resource="B" style="width: 79px; border-right: 1px solid #000000; 
        border-left: 1px solid #000000; border-bottom: 1px solid #000000; background-color: #ECE9D8; 
        font-family: Tahoma; font-size: 8pt; color: #000000; cursor: default;"> 
        <div unselectable="on" style="margin-left: 4px; height: 19px; line-height: 19px; 
         overflow: hidden;"> 
         Room B</div> 
       </td> 
       <td valign="top" unselectable="on" style="width: 1px; border-bottom: 1px solid black; 
        background-color: #FFF4BC;"> 
        <div unselectable="on" style="position: relative; height: 19px; overflow: none;"> 
         <div unselectable="on" onclick="javascript:event.cancelBubble=true;alert('2');" style="position: absolute; 
          left: 200px; top: -1px; width: 398px; height: 19px; border: 1px solid #000000; 
          background-color: #FFFFFF; white-space: nowrap; overflow: hidden; font-family: Tahoma; 
          font-size: 11px; cursor: pointer;"> 
          <div unselectable="on" style="width: 400px; margin-left: -1px; height: 2px; background-color: Blue; 
           font-size: 1px; position: relative;"> 
          </div> 
          <div unselectable="on" style="width: 398px; height: 1px; background-color: #000000; 
           font-size: 1px; position: relative;"> 
          </div> 
          <div unselectable="on" style="display: block; padding-left: 1px;"> 
           Event 3 
          </div> 
         </div> 
        </div> 
       </td> 
       <td unselectable="off" onclick="javascript:alert('2012-04-01T00:00:00, B');" onmouseover="this.style.backgroundColor='#FFED95';" 
        onmouseout="this.style.backgroundColor='#FFF4BC';" style="border-bottom: 1px solid #000000; 
        width: 19px; background-color: #FFF4BC; cursor: pointer;"> 
        <div unselectable="on" style="display: block; width: 18px; height: 19px; border-right: 1px solid #EAD098;"> 
         <!-- --> 
        </div> 
       </td> 
       <td unselectable="off" onclick="javascript:alert('2012-04-02T00:00:00, B');" onmouseover="this.style.backgroundColor='#FFED95';" 
        onmouseout="this.style.backgroundColor='#FFFFD5';" style="border-bottom-width: 1px; 
        border-bottom-style: solid; border-bottom-color: rgb(0, 0, 0); width: 20px; cursor: pointer; 
        background-color: rgb(255, 255, 213);"> 
        <div unselectable="on" style="display: block; width: 19px; height: 19px; border-right: 1px solid #EAD098;"> 
         <!-- --> 
        </div> 
       </td> 
       <td unselectable="off" onclick="javascript:alert('2012-04-03T00:00:00, B');" onmouseover="this.style.backgroundColor='#FFED95';" 
        onmouseout="this.style.backgroundColor='#FFFFD5';" style="border-bottom: 1px solid #000000; 
        width: 20px; background-color: #FFFFD5; cursor: pointer;"> 
        <div unselectable="on" style="display: block; width: 19px; height: 19px; border-right: 1px solid #EAD098;"> 
         <!-- --> 
        </div> 
       </td> 

'

回答

1

它看起來像你剛纔收到你的過濾器有點不對的語法。您需要使用一個"attribute equals" selector

$("table").selectable({ 
    filter: 'tbody td[unselectable="off"]' 
}); 

目前你正在尋找unselectable類型的任何元素是td元素的後裔,並使用僞選擇稱爲:off,這兩者都不存在。

+0

Thanx James。但顏色不會改變..任何想法。 – 2012-04-18 10:38:57

相關問題