Solved

passing parameters to jquery

Posted on 2012-03-27
2
373 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
Comment Utility
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
Comment Utility
This worked perfectly!!!
Thank you so much.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

762 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

12 Experts available now in Live!

Get 1:1 Help Now