The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to have something start hidden
Felixdm
post Jun 20 2016, 09:52 AM
Post #1





Group: Members
Posts: 1
Joined: 20-June 16
Member No.: 24,350



[b]Hello

I don't know how to start something hidden, and then when you are clicking on a button or a text, it will show.
Hope you can help me, and that you understand what i mean. Let me know if i need to explain further.[b]

(yes this i directly taken from W3School)




<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("p1").toggle();
});
});
</script>
</head>
<body>

<center><button id="hide">Creative</button>


<p1><strong><center>Basic rules</strong><p>
<p1>1. Do not scam</p>

</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jun 20 2016, 11:52 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(Felixdm @ Jun 20 2016, 04:52 PM) *

I don't know how to start something hidden

I don't do jQuery, but you can probably use some hide() function or similar to hide it in the document ready function. But there is no valid HTML element called P1, maybe you want to use a CLASS attribute instead? Here's an example:

CODE
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".foo").hide();
$("#hide").click(function(){
$(".foo").toggle();
});
});
</script>

<button id="hide">Creative</button>

<h3 class="foo">Basic rules</h3>
<p class="foo">1. Do not scam</p>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 12:03 PM