Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery toggle()函数工作不正常_Javascript_Jquery_Html - Fatal编程技术网

Javascript jQuery toggle()函数工作不正常

Javascript jQuery toggle()函数工作不正常,javascript,jquery,html,Javascript,Jquery,Html,是否可以使用jQuery toggle()函数隐藏和显示特定的html表格行 我有一个html表,它的第二行包含一个html表单。我希望在用户单击showdetals链接时显示表单,但jquerytoggle()函数的工作方式与预期不同。每当我单击“显示详细信息”链接时,它都会显示隐藏的表行,同时再次将其隐藏。下面是我的代码 jQuery代码 $(document).ready(function(){ $('.update_form').hide(); //hides the <

是否可以使用
jQuery toggle()
函数隐藏和显示特定的
html表格行

我有一个
html
表,它的第二行包含一个
html表单
。我希望在用户单击
showdetals
链接时显示表单,但
jquerytoggle()
函数的工作方式与预期不同。每当我单击“显示详细信息”链接时,它都会显示隐藏的表行,同时再次将其隐藏。下面是我的代码

jQuery代码

$(document).ready(function(){
      $('.update_form').hide(); //hides the <tr> tag when the document is ready

      $('#details').click(function(){
          $('.update_form').toggle();
      });
});

我无法找出我的代码出了什么问题。请帮帮我。谢谢。

在本例中,您将使用它,因为它是一个锚:

$('#details').click(function(e){
   e.preventDefault();
   $('.update_form').toggle();
});

@XeroElixir实际上不是。@DrixsonOseña对不起,我是jQuery的一个noob,但这对我来说一直都是这样。
$('#details').click(function(e){
   e.preventDefault();
   $('.update_form').toggle();
});