Javascript 如何隐藏表单的一部分并使其仅在单击“a”时可见;加上另一个“;按钮
请注意,单击按钮后,多个文本字段框将可见,而不仅仅是一个 以下是一个简单的jQuery,可用于您的情况:Javascript 如何隐藏表单的一部分并使其仅在单击“a”时可见;加上另一个“;按钮,javascript,jquery,html,css,Javascript,Jquery,Html,Css,请注意,单击按钮后,多个文本字段框将可见,而不仅仅是一个 以下是一个简单的jQuery,可用于您的情况: <!DOCTYPE html> <html> <head> <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" /> <script src="http://co
<!DOCTYPE html>
<html>
<head>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
input[type='text']
{
display: none;
}
</style>
</head>
<body>
<form id='frm1'>
<input type='text' />
<input type='text' />
<input type='text' />
<button id='btnShowInputs'>Show Inputs</button>
</form>
<script>
$("#btnShowInputs").click(function () {
$("#frm1 input[type='text']").css("display", "block");
});
</script>
</body>
</html>
JS-Bin
输入[type='text']
{
显示:无;
}
显示输入
$(“#btnShowInputs”)。单击(函数(){
$(“#frm1输入[type='text']”)css(“显示”、“块”);
});
以下是一个简单的jQuery查询:
<!DOCTYPE html>
<html>
<head>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
input[type='text']
{
display: none;
}
</style>
</head>
<body>
<form id='frm1'>
<input type='text' />
<input type='text' />
<input type='text' />
<button id='btnShowInputs'>Show Inputs</button>
</form>
<script>
$("#btnShowInputs").click(function () {
$("#frm1 input[type='text']").css("display", "block");
});
</script>
</body>
</html>
JS-Bin
输入[type='text']
{
显示:无;
}
显示输入
$(“#btnShowInputs”)。单击(函数(){
$(“#frm1输入[type='text']”)css(“显示”、“块”);
});
以下是一个简单的jQuery查询:
<!DOCTYPE html>
<html>
<head>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
input[type='text']
{
display: none;
}
</style>
</head>
<body>
<form id='frm1'>
<input type='text' />
<input type='text' />
<input type='text' />
<button id='btnShowInputs'>Show Inputs</button>
</form>
<script>
$("#btnShowInputs").click(function () {
$("#frm1 input[type='text']").css("display", "block");
});
</script>
</body>
</html>
JS-Bin
输入[type='text']
{
显示:无;
}
显示输入
$(“#btnShowInputs”)。单击(函数(){
$(“#frm1输入[type='text']”)css(“显示”、“块”);
});
以下是一个简单的jQuery查询:
<!DOCTYPE html>
<html>
<head>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
input[type='text']
{
display: none;
}
</style>
</head>
<body>
<form id='frm1'>
<input type='text' />
<input type='text' />
<input type='text' />
<button id='btnShowInputs'>Show Inputs</button>
</form>
<script>
$("#btnShowInputs").click(function () {
$("#frm1 input[type='text']").css("display", "block");
});
</script>
</body>
</html>
JS-Bin
输入[type='text']
{
显示:无;
}
显示输入
$(“#btnShowInputs”)。单击(函数(){
$(“#frm1输入[type='text']”)css(“显示”、“块”);
});
display:none
<a id="toggleform" href="#">Toggle Form</a>
<div id="hideform">
// form elements in here
</div>
或者,如果不想切换隐藏:
$( "#toggleform" ).on( "click", function() {
$('#hideform').show();
});
您的CSS:
#hideform {display:none;}
这里有一把小提琴演示:
display:none
<a id="toggleform" href="#">Toggle Form</a>
<div id="hideform">
// form elements in here
</div>
或者,如果不想切换隐藏:
$( "#toggleform" ).on( "click", function() {
$('#hideform').show();
});
您的CSS:
#hideform {display:none;}
这里有一把小提琴演示:
display:none
<a id="toggleform" href="#">Toggle Form</a>
<div id="hideform">
// form elements in here
</div>
或者,如果不想切换隐藏:
$( "#toggleform" ).on( "click", function() {
$('#hideform').show();
});
您的CSS:
#hideform {display:none;}
这里有一把小提琴演示:
display:none
<a id="toggleform" href="#">Toggle Form</a>
<div id="hideform">
// form elements in here
</div>
或者,如果不想切换隐藏:
$( "#toggleform" ).on( "click", function() {
$('#hideform').show();
});
您的CSS:
#hideform {display:none;}
这里有一把小提琴演示它:试试这个
HTML
<input type="button" onclick="javascript:show_text_boxes();" value="Show Textboxes" />
<input type="button" onclick="javascript:hide_text_boxes();" value="Hide Textboxes" />
<input type="text" id="textbox1" name="textbox1" style="display:none;"/>
<input type="text" id="textbox2" name="textbox2" style="display:none;" />
<input type="text" id="textbox3" name="textbox3" style="display:none;" />
试试这个
HTML
<input type="button" onclick="javascript:show_text_boxes();" value="Show Textboxes" />
<input type="button" onclick="javascript:hide_text_boxes();" value="Hide Textboxes" />
<input type="text" id="textbox1" name="textbox1" style="display:none;"/>
<input type="text" id="textbox2" name="textbox2" style="display:none;" />
<input type="text" id="textbox3" name="textbox3" style="display:none;" />
试试这个
HTML
<input type="button" onclick="javascript:show_text_boxes();" value="Show Textboxes" />
<input type="button" onclick="javascript:hide_text_boxes();" value="Hide Textboxes" />
<input type="text" id="textbox1" name="textbox1" style="display:none;"/>
<input type="text" id="textbox2" name="textbox2" style="display:none;" />
<input type="text" id="textbox3" name="textbox3" style="display:none;" />
试试这个
HTML
<input type="button" onclick="javascript:show_text_boxes();" value="Show Textboxes" />
<input type="button" onclick="javascript:hide_text_boxes();" value="Hide Textboxes" />
<input type="text" id="textbox1" name="textbox1" style="display:none;"/>
<input type="text" id="textbox2" name="textbox2" style="display:none;" />
<input type="text" id="textbox3" name="textbox3" style="display:none;" />
我有另一个问题,你应该在你的描述中包括:是否可以多次单击“添加另一个”按钮,以及在第一次和第二次单击后会发生什么情况(如果可能)?@部长,如果你有问题,最好是从这个角度开始新的问题。@ZaLiTHkA,这是对上述问题的澄清问题(不是另一个问题)。我设想一个带有文件字段的表单,其中有“添加另一个”按钮,因此可以添加更多文件(例如,多行文件的文件字段+标题)。这就是要求“用户3205736”澄清问题的原因,以防下面的答案无助于找到正确的解决方案。(我很抱歉,如果我的英语太差了,并且在我的第一次评论中不清楚)公平点,但是应该注意;即使在复制、定位和读取
文件
输入字段的多个副本时,从用户界面的角度来看,文本或输入
字段也应该没有区别。因此,我建议提出一个新问题我还有一个问题,你应该在你的描述中包括:是否可以多次单击“添加另一个”按钮,以及在第一次和第二次单击后会发生什么情况(如果可能)?@部长,如果你有问题,最好是开始一个新问题。@ZaLiTHkA,这是对上述问题的澄清问题(不是另一个问题)。我设想一个带有文件字段的表单,其中有“添加另一个”按钮,因此可以添加更多文件(例如,多行文件的文件字段+标题)。这就是要求“用户3205736”澄清问题的原因,以防下面的答案无助于找到正确的解决方案。(我很抱歉,如果我的英语太差了,并且在我的第一次评论中不清楚)公平点,但是应该注意;即使在复制、定位和读取文件
输入字段的多个副本时,从用户界面的角度来看,文本或输入
字段也应该没有区别。因此,我建议提出一个新问题我还有一个问题,你应该在你的描述中包括:是否可以多次单击“添加另一个”按钮,以及在第一次和第二次单击后会发生什么情况(如果可能)?@部长,如果你有问题,最好是开始一个新问题。@ZaLiTHkA,这是对上述问题的澄清问题(不是另一个问题)。我设想一个带有文件字段的表单,其中有“添加另一个”按钮,因此可以添加更多文件(例如,多行文件的文件字段+标题)。这就是要求“用户3205736”澄清问题的原因,以防下面的答案无助于找到正确的解决方案。(我很抱歉,如果我的英语太差了,并且在我的第一次评论中不清楚)公平点,但是应该注意;即使在复制、定位和读取文件
输入字段的多个副本时,从用户界面的角度来看,与文本
或