2013-04-15 44 views
5

我有一個JavaScript滾動條,取代了正常的webkit/mozilla滾動條。它適用於所有其他divs只需鍵入div名稱「.element」,但我不知道如何做滾動條應用到文本區域?有誰知道我會如何做到這一點,將不勝感激任何人幫助感謝。如何將JavaScript滾動條添加到textarea?

JAVASCRIPT:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
<script src="assets/js/scroll/jquery.mousewheel.min.js"></script> 
<script src="assets/js/scroll/jquery.mCustomScrollbar.js"></script> 

<script> 
    (function($){ 
     $(window).load(function(){ 
      $(".bio textarea").mCustomScrollbar(); 
     }); 
    })(jQuery); 
</script> 

HTML:

<form action="includes/changebio.php" method="post" id="form1">   
<textarea id="bio" style="width: 442px; 
    margin-top:3px; 
    text-align:left; 
    margin-left:-2px; 
    height: 120px; 
    resize: none; 
    outline:none; 
    border: hidden;" textarea name="bio" data-id="bio" maxlength="710"><?php echo stripslashes($profile['bio']); ?></textarea> 
<input type="image" src="assets/img/icons/save-edit.png"class="bio-submit" name="submit" value="submit" id="submit"/> 
</form> 

回答

0

更改腳本如下:

<script> 
    (function($){ 
     $(window).load(function(){ 
      $("textarea#bio").mCustomScrollbar(); 
     }); 
    })(jQuery); 
</script> 

因爲,有帶班 「生物」 爲您的textarea沒有父元素。 你的情況選擇器是錯誤的。更改選擇器「textarea#bio」,將解決您的問題。

接受答案,如果它解決了你的問題。