Click here to Skip to main content
15,850,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey all
I have an asp.net repeater that generates divs that have a class called "newsItem" assigned to them
what I wanna do is write a function that hides all the divs of the above mentioned class except one div based on an integer parameter that i pass to the function

Example:
Lets say i have 5 divs with the class "newsItem"
if I pass the number 1 to the function, I want to show the 2nd div and hide the other 4 divs
thanks all in advance :)
Posted

1 solution

JQuery takes it as an array object which can be accessed with a index. try the below code. it should work
JavaScript
toggleNews = function(newsIndex) {
  $("div.newsItem").hide();
  $($("div.newsItem")[newsIndex]).show();
}
 
Share this answer
 
v3
Comments
Reda Makarem 27-Aug-13 2:15am    
many thanks buddy :)
works like a charm
John-ph 27-Aug-13 2:28am    
You're Welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900