两个输入使用slideToggle进行同一个div [英] Two inputs using slideToggle for same div

查看:82
本文介绍了两个输入使用slideToggle进行同一个div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有我的html代码:

 <div class="the-game" id="3">
    <div class="center">
    <input type="text" id="team_1" class="field">
    <span> X </span>
    <input type="text" id="team_2" class="field">
    </div>
    <input type="text" style="display:block;" maxlength="2" class="multi" value="1" id="number_times">
    <a href="#" class="action">GO</a>

<a href="#" id="show_guesses">show guesses</a>
<div class="guesses">
WHEN CLICK IN INPUT TOGGLE THIS DIV.
<ul>
<li>

    <input type="text" id="team_1" class="field" value="2">
    <span> X </span>
    <input type="text" id="team_2" class="field" value="3">
    </div>
</li>
</ul>
</div>
</div>

JavaScript:

Javascript:

$( "#the-game input" ).click(function() {


$(this).parent().parent().parent().next('.guesses').slideToggle(360, 'swing');


});

就像我说的那样,有两个输入未指定调用slideToggle的输入,有两个可以做到这一点,但是我想要:

Like i said, Have two inputs im not specifying the input that calls slideToggle, and have two that can do it, but i want:

当用户单击一个输入时,它会切换div,但是当单击另一个实例但又没有切换的输入(在一定时间之前)时,如果用户花了很多时间,可以使用另一个输入进行切换.

When a user click on an input its toggle the div, but when click on the other input that inst clicked yet no toggle (before a time), if its takes alot of time its can toggle using the other input.

推荐答案

我发现很难收集您想要实现的目标?首先,您的选择器需要更改以选择正确的元素:

I am finding it hard to gather what it is you are wanting to achieve? Firstly your selector needs changing to select the correct element:

$('#the-game input')$('.the-game input')

以下内容将对您的html输入元素进行切换:

The following will do a toggle on your html input element:

$(document).on('click', '.the-game input', function () {
    $('.guesses').slideToggle(360, 'swing');
});

您能否在第二个输入字段附近提供有关您要执行的操作的更多信息?

Can you provide more information around the second input field about what you want to do around it?

这篇关于两个输入使用slideToggle进行同一个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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