[英]wordpress submit comment by press enter in textarea
我希望能夠隱藏WordPress注釋表單的“提交”按鈕,並允許用戶通過按Enter鍵提交其評論,並通過按Shift + Enter獲取新行。 我已經在wp主題根文件中的comment.php文件末尾嘗試了這一行代碼。
<script>
$(function() {
$(".PostCommentFormCon textarea").keypress(function (e) {
if(e.which == 13 && !e.shiftKey) {
$(this).closest("form#commentform").submit();
e.preventDefault();
return false;
}
});}
</script>
但沒有機會。 有誰知道如何解決此代碼?
如果您設置為使用“提交按鈕”,則需要為您的提交按鈕提供一個ID:
<button style="display:none" id="submitbutton" type="submit" value="Submit">Submit</button>
並在用戶填寫完文本區域后顯示按鈕
<script>
$(function() {
$(".PostCommentFormCon textarea").blur(function (e) {
if(JQuery.trim(this.val) != ''){
$("#submitbutton").show();
}
});
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.