我在我的樹枝模板中有一個窗體,其中包含一個可滿足的跨度。我想獲得新的文本並將其附加到span,所以當表單被submited時它包含新文本。如何獲得滿意的跨度文本?
這裏是我的HTML表單:
<form action="{{ path('change') }}" method="post">
<span name="profil" class="profil" contenteditable="true">{{ prof.libel }}</span>
<button name="change" type="submit">
</button>
</form>
這是我的jQuery腳本:
<script>
$(document).ready(function() {
$('span.profil').change(function() {
$text = $(this).text();
$(this).append(document.createTextNode($text));
});
});
</script>
您是否知道您的HTML無效?你打開的按鈕元素缺少一個關閉角度支架 –
啊好吧,這是因爲我發佈此問題時刪除了一些代碼。但在我的項目中,我的代碼沒有遺漏任何東西。 – Susan