Solved

passing parameters to jquery

Posted on 2012-03-27
2
375 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
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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now