2013-02-08 77 views
0
<textarea id="bbcode_enabled"></textarea> 
<textarea id="bbcode_enabled"></textarea> 
<textarea id="bbcode_enabled"></textarea> 

$(document).ready(function() 
{ 
    $("#bbcode_enabled").each(function() { 
     $(this).bbcode({ 
      tag_bold:true, 
      tag_italic:true, 
      tag_underline:true, 
      tag_link:true, 
      tag_item:true, 
      tag_skill:true, 
      tag_own3d:true, 
      tag_youtube:true, 
      tag_twitch:true, 
      tag_color:false, 
      tag_image:true, 
      button_image:true 
     }); 
    }); 
}); 

它只將BBCode類應用於第一個textarea,忽略其他。 有什麼問題?每個函數適用於第一項

Ps。這是我正在使用的BBCode類。 http://pastebin.com/FqXasEmD

回答

6

因爲id的必須是uniqiue,它恰克到class

<textarea class="bbcode_enabled"></textarea> 
<textarea class="bbcode_enabled"></textarea> 
<textarea class="bbcode_enabled"></textarea> 

$(".bbcode_enabled").each(function() { 
    ... 
}); 
+0

它解決了問題,但是所有BB代碼的圖像只適用於頂級textarea的現在。你是否也能看到它,或者我應該選擇這個作爲答案? – 2013-02-08 22:23:29

+0

@LyverKinkki您可能希望更新您的問題或更多細節,或者如果它與'.each()'只有一次調用無關,則可以開始一個新問題。 – 2013-02-08 22:34:39

相關問題