0
在我的Ruby on Rails項目中,我想通過按鈕將按鈕的內容傳遞給列表。傳遞按鈕的值來追加,jquery,Ruby on Rails
這是我的腳本:
<script>
$(document).ready(function(){
$(document).on('click', ".btn2", function() {
$("ol").append("<li>Appended item</li>"); #<-- Problem here
});
});
</script>
這是我的按鈕:
<button class="btn2"><%= date %></button>
當我按下按鈕 「BTN2」,另一<li>Appended item</li>
被列到OL元素。現在,我想要的是,而不是「附加項目」,應該列出值<%= date%> - 值。例如:
<button class="btn2">10-11-2014</button>
應該加上 「2014年10月11日」 到列表中。
我該如何做到這一點?提前致謝!