简体   繁体   English

在JQuery中在两个div之间切换

[英]Switch between two divs in JQuery

I am tring to switch between two divs (a small text area and a bigger form field..sort of like twitter). 我正试图在两个div之间切换(一个较小的文本区域和一个较大的表单字段..类似twitter)。 The divs belong to two different classes like div属于两个不同的类,例如

<div class = first onClick = "show();" >

<div class = second style = "display:none;">
contains a form that is supposed to redirect to some other .php page via the "action" field
</div>

I have the following javascript 我有以下javascript

function show()
{
        $(".second").fadeIn('5');
        $(".first").fadeOut('5');

}

When the form in the class = "second" is clicked however the page simply refreshes and div = "first" is displayed (instead of redirecting to the page that the form points to) What am I doing wrong? 当单击class =“ second”中的表单,但是页面只是刷新并显示div =“ first”(而不是重定向到表单所指向的页面)时,我在做什么错?

It appears there may be an error in the action. 看来操作中可能有错误。 The jQuery should really have nothing to do with where the link is directing to. jQuery实际上应该与链接所指向的位置无关。

The problem is likely the form inside <div class="second"> . 问题可能是<div class="second">的表单。

It works on here: 它在这里工作:

http://jsfiddle.net/NMMVB/ http://jsfiddle.net/NMMVB/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM