After extensive searching online, I was unable to find a solution to my query...
In the process of developing a website concept for my portfolio, I decided to experiment with jQuery to enhance its interactivity. While I have successfully linked and implemented jQuery into my project, I encountered an issue where the CSS styling of my button disappears when using the .toggle method.
This is the current state of my jQuery code:
$(document).ready(function(){
$(".landingHideButton").click(function(){
$(".copy-background").toggle(2000);
$(".landingHideButton").html("Show Content");
});
});
The HTML structure I am working with is as follows:
<div id="landing">
<div class="copy-background">
<h4>Header</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed leo enim, euismod nec ultrices id, ultrices vitae nisl. Aenean pharetra congue tempor. Pellentesque nisi nisl, aliquam ut pulvinar sed, tristique pretium tortor. In commodo lobortis euismod. Aliquam nisl risus, rutrum sed facilisis id, ultrices a nisi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
<div class="landingHideButton">
<p>Hide Content</p>
</div>
</div>
Additionally, here is the typography CSS applied to the landingHideButton:
.landingHideButton p {
text-align: center;
font-family: Helvetica, Arial, sans-serif;
font-size: 10pt;
font-weight: 500;
color: #7d7d7d;
}
Upon clicking the button, the copyBackground
div, which houses all the text content, should toggle visibility according to the speed defined in my jQuery script. Simultaneously, I want the text inside the button to switch from "Hide Content" to "Show Content" to indicate to users that they can reveal the hidden content by clicking again. Although this functionality is operational, it disrupts the font size styling and alignment within the button upon activation.
If anyone has insights on preventing this behavior or offers a more streamlined approach to achieve the desired outcome, your guidance would be greatly appreciated. Given my limited experience in scripting – primarily self-taught through W3Schools.com – please provide straightforward explanations. To observe the scenario firsthand, visit darerdesign.com...