问题描述:

I have a submit button like so:

<input type="submit" value="Submit" id="submitButton" />

and I also have this awesomefont icon

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

I tried adding the class to the submit button, but that did not work.

网友答案:

Unless you are dead set on using <input>, using a <button> makes this quite a bit easier, but it is possible using the unicode version of search and prepending that with &#x:

#submitButton {
  font-family: FontAwesome;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<input type="submit" value="&#xf002" id="submitButton">
<button id="submitButton">
  <i class="fa fa-search"></i>
</button>
网友答案:

What about using a button?

<button type="submit" value="Submit" id="submitButton" />
  <i class="fa fa-search"></i> Submit
</button>
网友答案:

You could try the following - use button instead of input and the following code:

<button type="submit" id="submitButton">
    <i class="fa fa-search"></i> Submit
</button>
相关阅读:
Top