简体   繁体   English

使按钮类似于html中的span

[英]make a button similar to the span in html

I have a button like below with me. 我下面有一个按钮。

<button type="submit" class="search-btn" id="search-submit-header"></button>

It has certain functionality which I want to apply to this span so that It does the same work as the button. 它具有某些功能,我希望将其应用于此范围,以便它与按钮执行相同的工作。 I want to use the CSS of the span. 我想使用跨度的CSS。

<span class="search-btn">
    <a href="#"><i class="fa fa-search"></i></a>
</span>

How can I get this. 我怎么能得到这个。 ie Functionality of the button working on the span. 即在跨度上工作的按钮的功能。

Apologies for a dumb question. 对于一个愚蠢的问题表示歉意。

Simply put the style info to anchor tag. 只需将样式信息放入锚标记。 For Example check below line 例如检查下面的行

<a href="#" class="search-btn">
    <i class="fa fa-search"></i>
</a>

Note: Clear all the style information of anchor tag and write supporting javascript code 注意:清除锚标记的所有样式信息并编写支持的javascript代码

   function doSomething(){
     //your code
    }
   $('.search-btn').click(doSomething);

Try something like this 试试这个

 <!DOCTYPE html> <html> <body> <style> .ButtonSpan { /*width: 500px; height: 500px;*/ border: 1px solid black; background: #e0e0e0; padding: 25px; } </style> <button type="submit" class="ButtonSpan">test</button> <span class="ButtonSpan">test</span> </body> </html> 

  1. Find what css is currently applied on your <button> element. 查找当前在<button>元素上应用的css

    There are several ways to do it but the most simple one is (in chrome) you can right-click > inspect element > press "ctrl + shift + c" and click on button > elements tab > Computed tab (on RHS) and see what css is currently applied. 有几种方法可以做到,但是最简单的方法是(在Chrome中),您可以右键单击>检查元素>按“ ctrl + shift + c”,然后单击按钮>元素选项卡>计算选项卡(在RHS上),然后查看当前应用了什么css

  2. Copy major properties of css from there and apply them on span.search-btn class in css. 从那里复制css的主要属性,并将它们应用于css中的span.search-btn类。

    for example: 例如:

     span.search-btn { width: 20px; height: 10px; border: 1px solid black; padding: 20px; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 html 表格的复制按钮。 Firefox 和 Chrome 的结果不同。 我怎样才能使它相似 - Copy button for html table. Different results with firefox and Chrome. How can I make it similar 如何使图标的工作方式类似于角度5/6中的按钮? - How to make icon work similar to button in angular 5/6? 如何赋予 html 按钮与复选框类似的功能? - How to give html button a similar functions as a checkbox? 制作HTML <td> 类似于Zurbs响应表 - Make HTML <td> similar to Zurbs responsive tables 如何制作开关按钮/反向按钮。 类似于谷歌翻译 - How to make a switch button/reverse button. Similar to google translate 如何使用span标签和glyphicon而不是bootstrap上的按钮制作下拉菜单? - How to make a dropdown menu with span tag and glyphicon instead of button on bootstrap? 将鼠标悬停在ab标签上时如何显示跨度按钮? - How to make span button appear when mouseover a b tag? 如何使用跨度值选择单选按钮? - How to make radio button selected using span values? HTML/JQuery:禁用跨度/按钮单击(将其变灰并禁用单击) - HTML/JQuery: Disable span / button click (greying it out and disable click) 作法:按一下按钮,将html span(文字)更改为任何输入值 - How to: click button, change html span (text) to whatever input value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM