我需要执行以下操作:每个评论都有一个带有特定ID号的回复按钮,如何将此ID附加到表单操作链接,以便代码更改
<form action="http://www.mywebsite.com/comments/add_comment/1/" method="post" accept-charset="utf-8" enctype="multipart/form-data">
到
<form action="http://www.mywebsite.com/comments/add_comment/1/TheID" method="post" accept-charset="utf-8" enctype="multipart/form-data">
而不是专注于textarea?
这是按钮的代码:
<a href="javascript:void(0)" id="{$comment->ID}" class="profile_comment_reply_button">reply</a>
答案 0 :(得分:1)
在JQuery中:
var id = yourid;
var action = $("getyourform").attr("action"); //action without id
$("getyourform").attr("action",action+id); //add id to action
$("getyourform").children(input).focus(); //focus your input field