2011-04-18 164 views
2

我想创建一个提交链接而不是提交按钮。html提交链接

它看起来像任何普通的链接(蓝色和下划线),当你点击它,表单被提交。

编辑:是否有可能做到这一点没有JavaScript/jQuery的?

回答

3

没有JS,只有CSS

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

几乎完美...我建议添加光标:指针,像这样:style =“background:none; border-width:0px; color:blue; text-decoration:underline; cursor:pointer;” – werner 2013-12-13 19:10:39

0

jQuery的可以做到这一点很容易不够:

参见:http://api.jquery.com/submit/

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

我们可以做到这一点没有任何的jQuery/JavaScript的 – SuperString 2011-04-18 15:49:04

+0

呦你可以通过删除填充,边距,边框等来设置你的' submit“/>'看起来像一个链接,但我不这么认为,否则。不过,有人可能会说我是对的。 – 2011-04-18 15:50:09

+1

为什么加载整个框架,只是为了提交表单? – 2011-04-18 15:53:34

-1

你可以简单地通过使用jquery来实现这一点!

只要做下面的代码---

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

希望这有助于!

+0

为什么加载整个框架只是为了提交表单? – 2011-04-18 15:51:42

+0

你也可以这样做。但为了简单起见,使用Jquery。 – 2011-04-18 15:52:52

+0

Jquery是另一个让事情变得更加复杂的层,例如提交表单 – 2011-04-18 15:54:23

0

您可以将按钮设置为链接样式。即

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

我会做一个样式表,而不是内联样式,但你得到的图片。

1

当然!

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; 
} 

这里举例:http://fiddle.jshell.net/Shaz/AQDcD/1/