我想要一个锚点应该像输入类型提交按钮 [英] i want a anchor should act like and input type submit button
本文介绍了我想要一个锚点应该像输入类型提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是一个实际使用输入类型提交的jquery插件库,但我在锚点上设计了我的按钮。我不想使用
< input type =button>
或
< input type =submit>
我想使用锚点,如
< a href =javascript to submit the form>< / a>
这里是我想要使用的jquery代码
{
var submit = $('< button type =submit/>');
submit.html(settings.submit);
}
$(this).append(submit);
if(settings.cancel){
/ *如果给定的html字符串使用* /
if(settings.cancel.match(/> $ /)){
var cancel = $(settings.cancel);
/ *否则使用给定字符串作为文本的按钮* /
} else {
var cancel = $('< button type =cancel/>');
如何使用锚点而不是按钮。
解决方案
如果你想让一个定位标记像一个按钮一样执行此操作,就可以执行此操作。
<! - 您的表格 - >
< form id =submit_this> .....< / form>
< a id =fakeanchorhref =#>< / a>
< script>
$(a#fakeanchor)。click(function()
{
$(#submit_this)。submit();
return false;
});
< / script>
i want a anchor should act like and input type submit button. i am using a jquery plugin library that actually uses input type submit but i have styled my buttons on anchors. i dont want to use
<input type="button">
or
<input type="submit">
i want to use anchors such as
<a href="javascript to submit the form" ></a>
and here is my jquery code where i want to use
{
var submit = $('<button type="submit" />');
submit.html(settings.submit);
}
$(this).append(submit);
}
if (settings.cancel) {
/* if given html string use that */
if (settings.cancel.match(/>$/)) {
var cancel = $(settings.cancel);
/* otherwise use button with given string as text */
} else {
var cancel = $('<button type="cancel" />');
how to use anchors instead of button.
解决方案
If you want an anchor tag to act like a button just do this
<!--YOUR FORM-->
<form id="submit_this">.....</form>
<a id="fakeanchor" href="#"></a>
<script>
$("a#fakeanchor").click(function()
{
$("#submit_this").submit();
return false;
});
</script>
这篇关于我想要一个锚点应该像输入类型提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文