简体   繁体   中英

html form button vs input type=“submit” vs this.submit()?

What is the proper standards compliant semantic way to have a submit button on a form? I don't need images or backgrounds in the buttons, just simple text, maybe a gradient background with curved corners (using CSS3). These are the ways I know of:

<input type="submit" value="click here"/>

<button>click here</button>

<span class="button">click here</span>
<script>
$('.button').click(function() {
  this.submit();
}
</script>

I would think input type="submit" is the proper button since that's what it was designed for?

The standard is of course using the <input type="submit" value="click here"/>

A button with a javascript function wouldn't work anymore if javascript is disabled

<input type="image" src="button_image_url"/>

behaves the same way as a submit button if ever you need images to make it more fancy if you are lazy to style it with CSS

In your case, I assume that you are having a hard time styling the submit button. If so then here's the reference I always have been using until jquery-ui came into the scene.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM