[英]jquery show/hide content based on button
I have a product page and i would like to add a tech spec button to the page which will open and close a show hide that is to be situated below the product description. 我有一个产品页面,我想在该页面上添加一个技术规格按钮,该按钮将打开和关闭位于产品说明下方的皮革。 I need the user to be taken down to the tech spec when the show hide opens. 打开秀皮时,我需要将用户引导至技术规格。
I think i need to use jquery but when the show/hide is hidden, ie nobody has pressed the button the footer should come up, so there shouldnt be any white space. 我想我需要使用jquery,但是当show / hide隐藏时,即没有人按下按钮,页脚应该显示出来,因此不应有任何空格。
any examples links that i could refer too? 我也可以参考任何示例链接吗?
could anyone be kind to make me a little jsfiddle? 有人可以让我变得有点傻吗?
Thanks 谢谢
Really simple with jQuery slideToggle
: 使用jQuery slideToggle
非常简单:
http://jsfiddle.net/r7Qf7/12/ (example with new scrolling on button click). http://jsfiddle.net/r7Qf7/12/ (示例是在按钮单击时进行新滚动)。
Scrolling to the tech specs section once the button is clicked can be accomplished with the animate
function in jQuery, like so. 单击按钮后,滚动到技术规格部分可以使用jQuery中的animate
功能来完成。
$('html,body').animate({
scrollTop: $("#techspecs").offset().top
}, 'slow');
First, you've got to add the click event to the button, after the document is ready: 首先,在文档准备好之后,您必须将click事件添加到按钮:
$(document).ready(function(){
$("#Button_ID").click(function(){
$('#Tech_Spec').toggle();
});
});
jsfiddle: http://jsfiddle.net/YEtBy/ jsfiddle: http : //jsfiddle.net/YEtBy/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.