Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

passing parameters to jquery

Posted on 2012-03-27
2
Medium Priority
?
387 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

618 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