Javascript JQuery脚本按代码的链接(滑动表单脚本) [英] Javascript JQuery Script click link by code (Sliding Form Script)

查看:65
本文介绍了Javascript JQuery脚本按代码的链接(滑动表单脚本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用花式滑动表单..演示单击此处:

I am using Fancy Sliding Form .. Demo Click here:

底部有一些用于导航的标签/按钮.

There are some tabs/buttons for navigation at the bottom.

当我用鼠标单击不直接在选项卡上的链接时,我需要能够掌握不同的步骤(自动单击).

I need to be able to tigger the different steps (auto clicking) when I click on a link not directly on the tab with my mouse.

我尝试为每个步骤添加一个ID,然后创建一个链接:下一个"选项卡 然后是下面的jquery:

I've tried adding an id to each step and then create a link: Next Tab then the jquery below:

<script>
$("#mytrigger").click(function(e) {
 e.preventDefault();
 $("#step2").trigger("click");
});
</script>

但这没用.

更新:

我把它们放在一起却无法正常工作...我不是在这样做吗?

I put this together and it's not working ... I'm I not doing this right?

<a class="mytrigger" href="#">Click Here</a>
<script>
$('a.mytrigger').click(function(e){
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
e.preventDefault();
});
</script>

这是我的导航:

<div id="navigation" style="display:none;">
<ul>
<li class="selected">
<a href="#">Step 1</a>
</li>
<li>
<a href="#">Step 2</a>
</li>
<li>
<a href="#">Step 3</a>
</li>
<li>
<a href="#">Step 4</a>
</li>
<li>
<a href="#">Step 5</a>
</li>
<li>
<a href="#">Step 6</a>
</li>
</ul>
</div>

推荐答案

我真的不能测试它,但这应该可以工作(基于插件的来源):

I'm not really able to test this, but that should work (based on the source of the plugin) :

$('a.mytrigger').click(function(e){
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
e.preventDefault();
});

$('a.mytrigger').click(function(e){
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
e.preventDefault();
});

当前"变量是在slide.form.js中定义的

The 'current' var is defined in sliding.form.js

编辑:
好吧,我错了,对不起. 这是一个工作示例: http://jsfiddle.net/dCmA7/1/
(完整大小: http://jsfiddle.net/dCmA7/1/embedded/result/)

Edit :
Well, I was wrong, sorry. Here is a working demo : http://jsfiddle.net/dCmA7/1/
(full size : http://jsfiddle.net/dCmA7/1/embedded/result/)

为了使事情尽可能简单,您不必修改导航.
像这样创建您的链接:
a href="#step1" class="mytrigger">link

To keep things as simple as possible, you don't have to modify the navigation.
Create your link like this :
a href="#step1" class="mytrigger">link

然后添加此javascript:

Then add this javascript :

$("a.mytrigger").click(function(e){  
    var index = $(this).attr("href").substr(5);  
    $('#navigation li:nth-child('+parseInt(index)+') a').click();  
    e.preventDefault();  
});

这篇关于Javascript JQuery脚本按代码的链接(滑动表单脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆