当我点击jquery按钮时它会隐藏文本但是当我再次点击它时没有任何反应。为什么? [英] When I click on jquery button it hides the text but when I click on it again nothing happens. Why?

查看:78
本文介绍了当我点击jquery按钮时它会隐藏文本但是当我再次点击它时没有任何反应。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站使用jQuery来隐藏和显示一个按钮。我得到它来隐藏我的文本,按钮更改它的名称,但我不能让它再次显示文本,按钮保持不变。我的代码中遗漏了什么吗?



这是我的HTML代码:



I have a website that uses jQuery to Hide and Show with one button. I got it to hide my text and the button changes it's name but I can't get it to Show the text again and the button stays the same. Did I miss something in my code?

Here is my HTML code:

<!DOCTYPE html>

<html lang="en">

<head>
	<title>Path of Light Yoga Studio :: Classes</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
	<script src="jquery/yoga.js" type="text/javascript"></script>
</head>
<body>
	<div id="wrapper">
	<header><h1>Path of Light Yoga Studio</h1></header>
		<p></p>
			<a href="index.html">Home</a>  
			<a href="Classes.html">Classes</a> 
			<a href="Schedule.html">Schedule</a> 
			<a href="Contact.html">Contact</a>
			<a href="Store.html">Store</a>
		<p></p>
	
		<p></p><div id="hero"></div><p></p>
		<br>
			<h2>Yoga Classes</h2>
		<br>
		<dl>
			<dt>Gentle Hatha Yoga</dt>
			<div id="hideme1">Intended for beginners and anyone wishing a grounded foundation in the practice of yoga, 
				this 60 minute class of poses and slow movement focuses on asana(proper alignment and posture),
				pranayama (breath work), and guided meditation to foster your mind and body connection.<p></p></div>
			<br>
			<dt>Vinyasa Yoga</dt>
			<div id="hideme2">Although designed for intermediate to advanced students, geginners are welcome to sampe this 60 minute class 
				that focuses on breath-synchronized movement -- you will inhale and exhale as you flow energetically through 
				yoga poses.<p></p></div>	
			<br>
			<dt>Restorative Yoga</dt>
			<div id="hideme3">This 90 minute class features very slow movement and long poses that are supported by a chair or wall. This calming, 
				restorative experience is suitable for students of any level of experience.
				This practice can be a perfect way to help rehabilitate an injury.<p></p></div>
			
		</dl>
		<button id="hide">Hide Descriptions</button>
	

        Copyright 2016 © Path of Light Yoga<br>
        <a>khopkin5@my.westga.edu</a>

</div>
</body>





这是我的jQuery代码:





Here is my jQuery Code:

$(document).ready(function(){
    $("#hide").click(function(){
        $("#hideme1").show();
			$("#hideme2").show();
				$("#hideme3").show();
					$('#hide').text('Hide Descriptions');				
    });
    $("#hide").click(function(){
        $("#hideme1").hide();
			$("#hideme2").hide();
				$("#hideme3").hide();
					$('#hide').text('Show Descriptions');	
    });
});





我尝试过:



我试图通过翻转来改变代码并且没有任何反应。我尝试添加.toggle,但是当页面加载时按钮消失,文本就消失了。



What I have tried:

I have tried to change the code around by flipping it and nothing happens. I try adding a .toggle but when the page loads the button disappears so does the text.

推荐答案

document )。ready( function (){
(document).ready(function(){


#hide)。click( function (){
("#hide").click(function(){


#hideme1)。show();
("#hideme1").show();


这篇关于当我点击jquery按钮时它会隐藏文本但是当我再次点击它时没有任何反应。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆