如何使用图像作为提交按钮?

时间:2022-07-20 18:55:22

Can someone help to change this to incorporate an image called BUTTON1.JPG instead of the standard submit button?

有人能帮忙修改一下,合并一个名为BUTTON1的图像吗?JPG而不是标准的提交按钮?

<form id='formName' name='formName' onsubmit='redirect();return false;'>
    <div class="style7">
        <input type='text' id='userInput' name='userInput' value=''>
        <input type='submit' name='submit' value='Submit'>
    </div>
</form> 

6 个解决方案

#1


51  

Use an image type input:

使用图像类型输入:

<input type="image" src="/Button1.jpg" border="0" alt="Submit" />

The full HTML:

完整的HTML:

<form id='formName' name='formName' onsubmit='redirect();return false;'>
    <div class="style7">
        <input type='text' id='userInput' name='userInput' value=''>
        <input type="image" name="submit" src="/Button1.jpg" border="0" alt="Submit" />
    </div>
</form> 

#2


8  

Why not:

为什么不:

<button type="submit">
<img src="mybutton.jpg" />
</button>

#3


6  

Use CSS :

使用CSS:

input[type=submit] {

background:url("BUTTON1.jpg");

}

For HTML :

HTML:

<input type="submit" value="Login" style="background:url("BUTTON1.jpg");">

#4


4  

Just remove the border and add a background image in css

只需删除边框并在css中添加背景图像

Example:

例子:

$("#form").on('submit', function() {
   alert($("#submit-icon").val());
});
#submit-icon {
  background-image: url("https://pixabay.com/static/uploads/photo/2016/10/18/21/22/california-1751455__340.jpg"); /* Change url to wanted image */
  background-size: cover;
  border: none;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: transparent;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="form">
  <input type="submit" id="submit-icon" value="test">
</form>

#5


1  

<form id='formName' name='formName' onsubmit='redirect();return false;'>
        <div class="style7">
    <input type='text' id='userInput' name='userInput' value=''>
    <img src="BUTTON1.JPG" onclick="document.forms['formName'].submit();">
</div>
</form>

#6


-3  

HTML:

HTML:

<button type="submit" name="submit" class="button">
  <img src="images/free.png" />
</button>

CSS:

CSS:

.button {  }

#1


51  

Use an image type input:

使用图像类型输入:

<input type="image" src="/Button1.jpg" border="0" alt="Submit" />

The full HTML:

完整的HTML:

<form id='formName' name='formName' onsubmit='redirect();return false;'>
    <div class="style7">
        <input type='text' id='userInput' name='userInput' value=''>
        <input type="image" name="submit" src="/Button1.jpg" border="0" alt="Submit" />
    </div>
</form> 

#2


8  

Why not:

为什么不:

<button type="submit">
<img src="mybutton.jpg" />
</button>

#3


6  

Use CSS :

使用CSS:

input[type=submit] {

background:url("BUTTON1.jpg");

}

For HTML :

HTML:

<input type="submit" value="Login" style="background:url("BUTTON1.jpg");">

#4


4  

Just remove the border and add a background image in css

只需删除边框并在css中添加背景图像

Example:

例子:

$("#form").on('submit', function() {
   alert($("#submit-icon").val());
});
#submit-icon {
  background-image: url("https://pixabay.com/static/uploads/photo/2016/10/18/21/22/california-1751455__340.jpg"); /* Change url to wanted image */
  background-size: cover;
  border: none;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: transparent;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="form">
  <input type="submit" id="submit-icon" value="test">
</form>

#5


1  

<form id='formName' name='formName' onsubmit='redirect();return false;'>
        <div class="style7">
    <input type='text' id='userInput' name='userInput' value=''>
    <img src="BUTTON1.JPG" onclick="document.forms['formName'].submit();">
</div>
</form>

#6


-3  

HTML:

HTML:

<button type="submit" name="submit" class="button">
  <img src="images/free.png" />
</button>

CSS:

CSS:

.button {  }