[英]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>
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
。
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.