Solved

passing parameters to jquery

Posted on 2012-03-27
2
379 Views
Last Modified: 2012-03-28
I am trying to use the jquery toggle function to show/hide multiple div blocks that are generated dynamically using a coldfusion loop. Each div block would have a separate and unique id that is automatically generated. I want to be able to use one toggle function to toggle each  div block separately but do not know how to pass div id names to the function to show/hide a specific block. (if there is a better way to do this, please let me know also)

For the id in the attached code I just picked seeall10 and whatever10 as one of the dynamically generated div tags but I would need to replace that with some sort of passed parameter or variable so that all div tags would work.

Thank you!
code.txt
0
Comment
Question by:cbeverly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 500 total points
ID: 37773061
you can try the following in jquery

$(function() {
$("p[id^='seeall']").click(function() {
   $(this).next("div").toggle();
});
});

This will solve your issue as this will bind your all  P tags with the id starting seeall.

Hope your problem has been fixed by the above code sample.
0
 

Author Closing Comment

by:cbeverly
ID: 37778265
This worked perfectly!!!
Thank you so much.
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question