[英]show form field on clicking a link with javascript/jquery
How can I show a form field by clicking a link , i want to show the field (with jquery/javascript) on samee place of link, so that link disappears and form box appears? 如何通过单击链接显示表单字段,我想在链接的相同位置显示该字段(使用jquery / javascript),以便链接消失并显示表单框? Thanks.
谢谢。
Hey, here's a simple example: 嘿,这是一个简单的例子:
CSS: CSS:
.myclassname .form{display:none;}
HTML: HTML:
<div class="myclassname">
<a href="#" class="mylink">Link</a>
<div class="form">
<input type="text" value="" name="myinput" id="myinput"/>
</div>
</div>
jQuery: jQuery的:
$(function(){
$('.myclassname .mylink').click(function(){
$(this).hide();
$('.myclassname .form').show();
return false;
});
});
Cheers 干杯
G. G。
Here is the simple code by using HTML and JavaScript. 这是使用HTML和JavaScript的简单代码。
<body>
<a href="#" id="mylink" onclick="myfunction();">MY</a>
<div id="myform" style="display:none">
<form>
<label>Name</label>
<input type="text">
<input type="submit">
</form>
</div>
<script>
function myfunction(){
document.getElementById("myform").style.display = "block";
document.getElementById("mylink").style.display = "none";
}
</script>
</body>
Thank's 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.