这可能是一个愚蠢的问题,但我试图复制我在rails中创建但在jquery中创建的链接。
Rails链接;
<%= link_to 'unfollow', dashboard_follow_index_path(blog: n['blog_name']), method: :post, remote: true, class: 'f-button' %>
输出;
<a class="f-button" data-remote="true" rel="nofollow" data-method="post" href="/dashboard/follow?blog=b">unfollow</a>
到目前为止,我在jquery中得到了什么;
var newLink = $("<a />", {
class : "f-button",
href : "I know how to get this blog name.",
method : "post",
rel : "nofollow",
text : "follow",
});
输出;
<a rel="nofollow" method="post" href="/dashboard/follow?blog=b" id="f-button">follow</a>
链接不起作用;
答案 0 :(得分:0)
使用JQuery
var newLink = $("<a />", {
'class' : 'f-button',
name : "link",
href : "you know how to get this blog name.",
method : "post",
rel : "nofollow",
text : "follow"
});