2013-03-19 57 views
0

我在我的項目中使用asp文本框和一些javascript代碼。jQuery庫1.4.4不允許在文本框中的空格

在看到我的文本框中的空格處於禁用狀態後,我遇到了其他人遇到的類似問題,並且得到了大多數JavaScript引起的這類問題。所以嘗試後,我得到了jQuery庫1.4.4是原因。但通過刪除,我的幻燈片將被禁用。

任何想法什麼可能是更好或適當的解決方案呢?

Here是樣本。

我試過的結果告訴我下面的文件「jq1.js」中的腳本正在引發這個問題。

$(function() { 
    $('#MainGalleryData .test').lightBox(); 
    $('#MainGalleryData2 .test').lightBox(); 
    $('#MainGalleryData3 .test').lightBox(); 
    $('#MainGalleryData4 .test').lightBox(); 
    $('#MainGalleryData5 .test').lightBox(); 
    $('#MainGalleryData6 .test').lightBox(); 
    $('#MainGalleryData7 .test').lightBox(); 
    $('#MainGalleryData8 .test').lightBox(); 
    $('#MainGalleryData9 .test').lightBox(); 
    $('#MainGalleryData10 .test').lightBox(); 
    $('#MainGalleryData11 .test').lightBox(); 
    $('#MainGalleryData12 .test').lightBox(); 

});

jQuery(document).ready(function() { 
    jQuery('#MainSlidesUl').fadeSlideShow(); 
}); 
+3

更新jQuery的:P – Sergio 2013-03-19 08:04:27

+0

我沒有和使用的1.8,但幻燈片保持禁用反正。 – John 2013-03-19 08:05:49

+0

不要瘦,這裏有任何extrasensory。向我們提供一些JsFiddle或代碼,您在哪裏面臨問題 – Sergio 2013-03-19 08:08:36

回答

1

有在<script src="js/jq1.js" type="text/javascript"></script> 搜索32一看,這是space鍵碼。你會發現下面的代碼:

if (settings.allowKeyboardCtrl) { 
     jQuery(document).bind('keydown', function (e) { 
      if (e.which == 39) { 
       var nextSlide = ActSlide - 1; 
       stopAutoplay(); 
       jumpTo(nextSlide); 
      } else if (e.which == 37) { 
       var prevSlide = ActSlide + 1; 
       stopAutoplay(); 
       jumpTo(prevSlide); 
      } else if (e.which == 32) { 
       if (intval) { stopAutoplay(); } 
       else { autoplay(); } 
       return false; 
      } 
     }); 
    } 

所以當按空格它將返回false,這是你的「錯誤」的原因。你應該禁用它或者檢查時,如果它是一個輸入,例如:

jQuery(document).bind('keydown', function (e) { 
    if ($(event.target).is('input') == false) { 
     ... 
    } 
}); 
+0

完美。但爲什麼這個條件用於幻燈片?順便說一句,我改變了一些其他號碼,並解決了問題。是不是改變了會造成另一個問題? – John 2013-03-19 09:04:43

+0

我無法告訴你幻燈片作者爲什麼這樣做。我的事件不認爲有必要通過按鍵控制幻燈片。你改變了什麼其他號碼?如果你改變它,例如65,你將無法輸入'a'。看看在JavaScript的關鍵代碼:http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes – iappwebdev 2013-03-19 09:08:37

+0

我改變了332爲一個嘗試,這將使條件無用的權利? – John 2013-03-19 09:10:27

相關問題