Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with a simple jQuery problem

Featured Replies

Hi all,

 

On a HTML page I have placed 12 flash animations within a span tag and have given each of those span tags the class flash. I have an anchor tag that with the class showall to show the flash animations and another anchor tag with the class hideall to hide them

 

What I want to end up doing in the end is having showall# open flash# and hideall# closing its corresponding flash#. Below is my current jQuery code running for the example from paragraph 1. Now how would I go about writing my new jQuery code without creating a 12 different sets of code merely with a change of character in the class names etc. Is there a smart way to do this using parameters or something?

 

Sorry, my JavaScript knowledge isn't that strong :unknw:

 

 <!-- this is in the <head> by the way -->
<script>
$(document).ready(function(){
  		$("span.flash").hide();
  		$("a.showall").click(function(){$("span.flash").slideDown(800)});
	$("a.hideall").click(function(){$("span.flash").fadeOut(800)});
  });
</script>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.