Javascript Rails按钮id和单击按钮事件
我正在使用rails应用程序,这是我正在使用的代码:Javascript Rails按钮id和单击按钮事件,javascript,jquery,ruby-on-rails,Javascript,Jquery,Ruby On Rails,我正在使用rails应用程序,这是我正在使用的代码: <%= button_to "New", :action => "update", remote: true%> “更新”,远程:真%> 现在我需要按钮id,这样我可以在单击时启动JavaScript事件,最初使用的简单html按钮是: <input id="btn" type="button" value="Save" action="update" alignment="center" /> 有什么
<%= button_to "New", :action => "update", remote: true%>
“更新”,远程:真%>
现在我需要按钮id,这样我可以在单击时启动JavaScript事件,最初使用的简单html按钮是:
<input id="btn" type="button" value="Save" action="update" alignment="center" />
有什么猜测吗?如图所示,没有办法直接做到这一点。我发现最好的方法是向父类添加一个id-span
效果很好
<span id="btn">
<%= button_to "New", :action => "update", remote: true%>
</span>
“更新”,远程:真%>