Encountering issues with JavaScript functionality upon clicking

I'm struggling to get the div element to slide up or down when clicked, but for some reason nothing is happening. I'm currently following a tutorial and have double-checked everything, yet I can't seem to pinpoint the issue. Any assistance in explaining what I'm doing wrong would be greatly appreciated. As a learner, I tend to make silly mistakes so please don't judge! :)

<!DOCTYPE html>

<head>
<script src="/assets/jquery.js"></script>
<link href='https://fonts.googleapis.com/css?family=Londrina+Shadow' rel='stylesheet' type='text/css'>
<style>
body {
  font-family: helvetica, sans-serif;
  margin: 0 auto;
  max-width: 600px;
  background: #232323;
}
div {
  height: 200px;
  background-size: cover;
  position: relative;
  margin: 40px 0 0 0;
  border-radius: 12px;
}
h1 {
  font-family: 'Londrina Shadow', cursive;
  text-align: center;
  font-size: 75px;
  color: #aaaaaa;
  margin: 60px 0 0 0;
}
h2 {
  text-align: center;
  color: #bbbbbb;
  margin: 0px 0 70px 0;
}
p {
  color: rgba(255,255,255,1);
  background: black;
  background: linear-gradient(bottom, rgba(0,0,0,1), rgba(0,0,0,.4));
  background: -webkit-linear-gradient(bottom, rgba(0,0,0,1), rgba(0,0,0,.4));
  background: -moz-linear-gradient(bottom, rgba(0,0,0,1), rgba(0,0,0,.4));
  padding: 10px;
  line-height: 28px;
  text-align: justify;
  position: absolute;
  bottom: 0;
  margin: 0;
  height: 30px;
}
small{
  opacity: 0;
}
.show-description p{
  height: 150px;
}
.show-description small{
  opacity: 1;
}

.first{
  background-image: url("http://dash.ga.co/assets/firstcourse.jpg");
}
.second{
  background-image: url("http://dash.ga.co/assets/secondcourse.jpg");
}
.dessert{
  background-image: url("http://dash.ga.co/assets/dessertcourse.jpg");
}
.price {
  float: right;
}
@media (max-width: 500px){
  h1{
    font-size: 50px;
    margin-top: 20px;
    line-height: 40px;
  }
  h2{
    font-size: 20px;
    margin: 20px 0 30px 0;
  }
  div{
    margin: 20px 12px 0 12px;
  }
  p{
    font-size: 20px;
    line-height: 24px;
  }
  small{
    font-size: 16px;
  }
}
</style>

</head>

<body>
<h1>esha's restaurant</h1>
<h2>a New York City eatery</h2>
<div class="first">
  <p>welsh onion soko <span class="price">$14</span><br />
  <small>Mustard sierra leone bologi kale chard beet greens black-eyed pea sorrel amaranth garlic tigernut spring onion summer purslane asparagus lentil. </small></p>
</div>

<div class="second show-description">
  <p>pastrami boudin tongue <span class="price">$22</span><br />
  <small>Tri-tip capicola kielbasa salami brisket chicken rump strip steak drumstick. Meatloaf chuck boudin ribeye pork jowl. Andouille bacon jowl meatloaf pork loin prosciutto bresaola.</small></p>
</div>
  
<div class="dessert">
  <p>fruitcake marzipan pudding dragee <span class="price">$8</span><br />
  <small>Lollipop tart cotton candy jelly-o carrot cake apple pie cupcake. Jelly-o bear claw ice cream candy canes.</small></p>
</div>
<script>
$('div').on('click', function() {
  $(this).toggleClass('show-description');
});
</script>
</body>

Answer №1

After encountering a similar problem, I discovered that disabling certain add-ons resolved the issue. It turned out that my ad-blocking software was causing interference. A shoutout to those who mentioned checking the console - your insights were invaluable.

In my opinion, tweaking the source code of the library isn't required if you've meticulously followed the tutorial step by step.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Link insertion column

How can I insert a hyperlink into this particular column? <div class="col-md-6" style="height: 125px;"> <div style="background: #ffffff;"></div> <div class="borde ...

How to alter row colors in SQL/PHP tables

echo "<tbody"; echo "<tr>"; echo "<td>{$id}</td>";// display customer Id echo "<td> {$firstname} {$lastname}</td>"; //display customer title,firstname,lastname echo "<td>{$date->format('h:i A')}</td> ...

A guide on how to assign a placeholder as the default value for a date picker

Currently using Vue3 with options API, and this question does not pertain to date formatting. Looking at the code provided on StackBlitz here, the default format for the date being initially set is dd.mm.yyyy. I am interested in knowing how to set the date ...

Executing operations on checkboxes on a webpage without access to model files

I am facing an issue with accessing the models file due to encryption in the software. Currently, my checkboxes are implemented using Ajax within a PHP query. Since it is Ajax-based, I am unable to manipulate actions through the URL. My goal is to extract ...

Ways to extract the variable value from two asynchronous functions

I need to create a script that generates live currency conversion rates for a given array of currencies. For example, if the array is ['USD','AUD','GBP'], I want the script to calculate conversions like USD->AUD, USD->GB ...

Match the input fields with the corresponding table columns

Could you assist me in adjusting the alignment of my inputs? I am looking to position them above the last two columns ("Primary price" and "Secondary price"). To provide clarity, I have included a wireframe. https://i.sstatic.net/Zq983.jpg I attempted to ...

Screen readers are unable to "read" text that is identified through aria-describedby

When enhancing my web application for accessibility, I encountered a challenge. I have implemented two required fields in a form that should display separate error messages as spans. To accomplish this, I am utilizing aria-invalid to signal when the fields ...

The most effective method for crafting a seaside parasol in the Three.js framework while maximizing resource usage

Being new to Three.js, I am really enjoying how easy it is to create simple scenes with minimal effort. Currently, I am working on designing a beach scene and my goal is to include 10 thousand beach umbrellas in the scene. To achieve this, I have been usin ...

HTML/JS Implementation: Back to Top Visual Element

- This website appears to be quite simple at first glance. However, I have encountered an issue where every time I scroll down and then click on the "About" menu option, it abruptly takes me back to the top of the page before displaying the section with a ...

Steer clear of using the onRowClick event for specific columns in a rich:dataTable

In my application, I am dealing with a rich:dataTable that consists of four columns. The first column contains a selectBooleanCheckBox element, which triggers an event named "CheckEvent" in the corresponding bean. Additionally, the rich:dataTable also sup ...

Combining hover and mousedown event listeners in jQuery: Tips and tricks

htmlCODE: <div class="original_circle" style="border-radius: 50%; background-color: blue; width: 40px; height:40px; z-index: 0"> <div class="another_circle" style="position:absolute; border-radius: 50%; background-color: coral; width: 40px; h ...

Guide on transferring selected table row using checkbox in HTML and sending the information to views.py file in Django

Hi there, I'm new to Python-Django and in need of help. I want to be able to pass the selected table row from a template to views.py with checkboxes checked using the POST method. Additionally, I would like to be able to select multiple rows. After su ...

Guide to scraping data from a table using Python and BeautifulSoup

I'm looking to extract information from the caranddriver.com website through web scraping. Specifically, I need to retrieve the trim lines and prices from a table. Since I am just starting out with coding, any input you can provide would be greatly a ...

What is the method for automatically scrolling a WebView HTML document?

I am seeking a way to implement autoscroll on my webpage. Here is the solution I have come up with: public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setCon ...

The select2 plugin seems to be having trouble recognizing the Li click functionality

I have a select menu that is using the select2 plugin. I am trying to add a class to the <select> element when a menu option is clicked, but it doesn't seem to be working as expected even after testing with an alert. https://jsfiddle.net/ysm4qh ...

CSS Troubleshooting: oversized div

I want to adjust the size of my lightbox, but I'm facing some issues. When I set max-width: 100%, the images appear too large for PC screens (img) and too small for cellphones (img). Conversely, with a max-width: 50% setting, the images are just right ...

A guide on implementing the MVC architecture in a web application with Node.js, Express, and PostgreSQL

I'm struggling with implementing the MVC architecture in my node web app, specifically when it comes to separating the model from the controller. Currently, I have the views properly organized (all my .ejs files) and I consider my app.js as the contr ...

What could be causing the difficulty in attaching a function to the onClick event of a div element?

I've been working on dynamically creating div elements and encountering an issue where the onClick method is not being properly attached to the newly created div. When I inspect the div using Firebug, instead of seeing the correct onClick function, I ...

Having difficulty displaying this code accurately on Google Chrome

I managed to create a hover effect over a series of images that displays additional information when hovered over. Below is the code I used: HTML <ul class="photo-grid"> <li> <a href="https://www.abglobal.com/" target="_blank"& ...

"Retrieving a unique identifier from a child page by using the href attribute in the parent page

Is it possible to load a specific ID from a child page and display that content in a dialog on the parent page when a link is clicked? I want to load the DIV ID "medical" when the medical link is clicked, and I am looking for a way to add a selector in the ...