当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How to generate a button tag with nested elements

问题描述:

I want to be able to generate a button tag with a nested icon element.

Particularly, I want to be able to use this:

<%= tag "input", { "class" => "btn btn-info", "type" => "button", "onclick"=> "codeAddress()" }%>

but with nested icon.

I tried putting in class icon-search, it worked but it didn't looked good.

I stumbled upon so many questions, they pointed at solutions like this.

And I altered the code of line to this :

<%= tag "input", { "class" => "btn btn-info", "type" => "button", "onclick"=> "codeAddress()" } do %>

<i class="icon-search"></i>

<% end %>

But none of them worked.

Also, this does not seem to do it neither.

I am using Rails 4 and Twitter-bootstrap-rails 2.x

网友答案:

Try this

<%= button_tag "name", type: 'button', class: "btn btn-info", onclick: "codeAddress()" do %>
   <i class="icon-search"></i>
<% end %>
分享给朋友:
您可能感兴趣的文章:
随机阅读: