Include an expand and collapse icon in a hyperlink

I have successfully implemented a functionality whereby clicking a link collapses other hidden names. However, I am now facing a challenge in trying to change an image once the link is clicked. Here is the code snippet that I currently have:

     $(document).ready(function() {


       $(".toggler").click(function(e) {

         e.preventDefault();

         //the data stored in the data-emails
         var emailData = ($(this).attr("data-emails"));

         //toggle the link clicked on
         $(".email" + emailData).toggle();

         $(".more").toggle();

         //select the parent and find the span so you can
         //toggle the "email-plus" class

         $(this).parent().find("span").toggleClass("email-plus");

         $(this).parent().find("span").toggleClass("less");


       });

     });
<table cellpadding="0" cellspacing="0" border="1">

  <tr style="vertical-align: bottom">
    <td>
      Names:
      <a href="#" class="toggler" data-emails="1">
        <span class="email-plus" style="text-transform: none;font-weight: bold;outline: 0;">All Names</span>
        <span class="more"><img src='more.png'></span>  <span class="less"><img src='less.png'></span>
      </a>
    </td>
  </tr>
  <tr style="vertical-align: top;display:none;" class="email1">
    <td colspan="6" cellpadding="0" cellspacing="0" style="vertical-align: top;">
      <p class="email1" style="display:none;font-weight: bold; margin-left: 44px; margin-top: 1px; margin-bottom: 3px;">Name 1</p>
      <p class="email1" style="display:none;font-weight: bold; margin-left: 44px; margin-top: 3px; margin-bottom: 3px;">Name 2</p>
      <p class="email1" style="display:none;font-weight: bold; margin-left: 44px; margin-top: 1px; margin-bottom: 2px;">Name 3</p>
    </td>
  </tr>

</table>

Appreciate your help in resolving this issue!

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

What is the method to automatically activate a "collapse" menu?

I am using the Bootstrap 4 theme on my website. I would like the menu called collapseMenuManage to automatically open when it is displayed. Below is the HTML code for my page: <div id="modal_aside_first" class="modal fixed-right pl-0 fade ...

Is there a way to use JavaScript to determine if GEARS is already installed on a system?

Does the existence of windows.gears not equal to undefined or what??? I am simply looking to use javascript to determine true or false based on whether the person has google Gears installed. ...

Executing a setInterval function in NodeJs without prolonging the process's lifespan

To better grasp what I need to do, I simplified the task at hand: we have a lengthy nodejs process with numerous queued async functions, making it impossible to predict when they will finish. Our goal is to create an update process that stores the current ...

Trying to connect a webpage to my CSS file

Lately, I've been diving into building a new website. It's still in its early stages and unfortunately, I'm struggling to get the style.css file to cooperate. Despite my best efforts scouring the internet for fixes, I haven't had much l ...

Serialization in ASP.NET MVC allows for the easy binding of data between models

I am encountering an issue with my ASP.NET MVC application where the model is not binding when I use the serialize and JSON.stringify methods for an Ajax call. Below is the JavaScript code and strongly-typed view that I am using: <script> funct ...

To interact with a specific cell in a table using Protractor, simply click

I have a dataset containing various elements such as images, text, and numbers. I am struggling to click on a specific text within the dataset. As someone new to e2e testing with Protractor, any assistance would be greatly appreciated. I specifically need ...

Extract information from a webpage using Selenium WebDriver

Currently, I am working on mastering Selenium, but I have hit a roadblock that I need assistance with. My task is to gather all the betting information for games from the following link and store it into an array. Given my limited experience with HTML an ...

Unable to retrieve the JSON response item

Currently, I am in the process of setting up an AJAX call with the intention of manipulating the response data. Upon inspecting my browser's network console, this is the response I am seeing: { "message": "success", "file": "dump.xml" } Thi ...

Struggling to get a complex jQuery script using the load() function to function correctly

I've encountered an issue with the jQuery load function. I'm trying to create an infinite scroll page that loads content from other pages as you scroll. However, I'm facing a problem where the load() function only executes properly once at a ...

Unable to run code from a script that has been released, Colorbox parent.$.fn.colorbox.close is not functional

My code has been running smoothly, carefully checking for any changes to input fields before closing the colorbox. However, a problem arises when trying to close the colorbox using parent.$.fn.colorbox.close after sending data back to the server. Specific ...

looping through the elements in a collection using a for-in loop

Issue with IE 11 Console Chrome Console Behavior When changing the word 'item' to 'anotherItem' in the loop like so: var obj = { id1: 'item 1', id2: 'item 2', id3: 'item 3' }; for (anothe ...

Passing PHP array to JavaScript and selecting random images from the array

Check out my PHP script below: <?php $all_images = glob("Images/Classes/{*.png, *.PNG}", GLOB_BRACE); echo json_encode($all_images); shuffle($all_images); ?> Here's the JavaScript code I'm using: functio ...

Find the index of two numbers in an array that equal a target sum

[https://drive.google.com/file/d/12qIWazKzBr1yJGpo1z106euXVJMKMwEa/view?usp=sharing][1]I am struggling to find the correct indices of two numbers in an array whose sum equals a target number provided as an argument. I attempted to solve this using a for ...

Encountered an error: The function run is not supported for the current bot command

Recently, I attempted to create a command handler in discord.js and encountered an issue when running the bot. A TypeError was thrown: TypeError: bot.commands.get(...).run is not a function The error occurs towards the end of the code snippet below. bot ...

Javascript Calculator with Dual Input Fields

I have been given a task to create a calculator by tomorrow using Javascript. Unfortunately, I am currently taking a distance course and Javascript has just been introduced in this assignment. While I am familiar with HTML and CSS, Javascript is something ...

The CSS is getting overridden by the a:-webkit-any-link user agent stylesheet

I've found myself faced with a page full of lists and links that I need to style individually. No matter what I try, the fonts and colors keep getting overridden by an unknown user agent stylesheet. I've experimented with styling the divs using c ...

Implementing jQuery time picker on dynamically created elements (e.g. with an 'Add more' button)

I have incorporated the jquery time picker into my project. It works perfectly for existing elements, but when I try to use it on dynamically created text fields within a form generated by JavaScript with an "Add More" button, it doesn't function as e ...

Looking for a single solution to have my background image in CSS cover the entire screen on both my computer and cell phone

I used the following code in my demo .html file: body{ background-image: url('https://i0.wp.com/www.socialnews.xyz/wp-content/uploads/2020/10/26/5573c6f0bee7ca021f4a8aecbaf6cbeb.jpg?quality=80&zoom=1&ssl=1'); -webkit-backgroun ...

Javascript - Incrementing value upon key press, but limited to occurring only once

I am currently working on a script where I need to increment a variable by 5 each time the up key is pressed. The issue I am facing is that the variable keeps increasing continuously from a single keypress, whereas I want it to increase in steps of 5 (e.g. ...

Attempting to construct a webpage with the ability to create visual content

I've been struggling to kick off this project because I'm uncertain about what exactly I should be looking into. I would really appreciate any guidance on where or how to start. The concept is to enable users to upload an image of a postcard, in ...