开发者

html submit links

I want to create a submit link instead of a submit button.

It looks like any ordinary link (blue and underlined) and when you click on it, the form is submitted.

Edit: is it possible to do this without javasc开发者_JAVA技巧ript/jquery?


No js, only CSS

<input type="submit" value="ABC" style="background:none; border-width:0px; color:blue; text-decoration:underline;" />


You can do it with Javascript:

<a href="#" onclick="document.formName.submit();return false;">submit form</a>

Edit:

This page:

http://www.beginningjavascript.com/Chapter4/exampleSubmitToLinks.html

has styled a button to look like a link, but it still uses Javascript to achieve it.


Sure!

HTML:

<form>
    <input type="text" placeholder="name" />
    <button type="submit">Submit</button>
</form>

CSS:

button {
    background: none;
    border: none;
    color: blue; text-decoration: underline;
    cursor: pointer;
}

Example here: http://fiddle.jshell.net/Shaz/AQDcD/1/


jQuery can do this easily enough:

See: http://api.jquery.com/submit/

$('.submit-link').click(function(){
  $('#form-id').submit();
});


You can style the button to look like a link. i.e.

<input type="submit" value="submit" style="cursor: pointer; background-color: transparent; text-decoration: underline; border: 0; color: blue;" />

I'd do it with a stylesheet, rather than the inline styles, but you get the picture.


You can achieve this simply by using jquery!

Just do the following code ---

$('.your-sumbmit-link').click(function (e) {
   e.preventDefault();
   $('.your-form').submit();
});

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜