JQuery :: Toggle/Switch For Multiple Items?
Dec 29, 2009
I'm looking for a lightweight way to be able to switch between 2 divs on a page.
I have found various ways to do this online with jQuery, but none of which are able to handle multiple switches and make it extendable across the pages of my website efficiently.
For example I could have 12 - 15 individual elements on a page (All with same style) each with an option to switch content e.g. "Click here to do something" then once clicked "it would reveal something" (Within that element/<li> tag) - so it's element specific.
For example:
Code:
<ul>
<li class="box>
Title
[Code]....
But of course as it's element specific you have to associate each id together but you can't have two id="2" - as that won't validate.....
Looking around, a perfect example can be seen at: [URL]
And because it's CMS driven and will have multiple categories/pages, you can't list all the id's with the javascript, so it has to be portable/OOP (Is that the word?) so just a main identifier in the JS...??
Where you click to reveal code and it switches div, but only for that element, it doesn't effect anything else.
View 2 Replies
ADVERTISEMENT
Oct 2, 2009
I have some divs I am toggling and there is a little + sign image I want to change to a - sign image when the toggle event occurs, but can't quite figure it out. Here is the toggle code I have (taken from
[Code]...
View 5 Replies
View Related
Jul 20, 2010
Can JQuery toggle be use to switch divs on page load instead of having to click a button to start the action? What would I have to write in the header to make this happen if this is possible?
View 2 Replies
View Related
Jan 26, 2010
I am trying to put the finishing touches on my client's website. The site was built with Wordpress as its CMS. For the site's 'Photos' page, I used the NextGen Gallery plugin to manage and display the image gallery. We (my programmer) made some modifcations to the plugin so that users could upload images from the frontend of the site. That was no problem.
Then I added a jQuery script that toggles each image's description text OFF and ON. It looks good on the 1st page of the gallery, but then if you click to page "2" you get taken to a screen that shows all the descriptions toggled ON. I don't know what's doing it, but something is causing all of these descriptions to show at once, which is NOT what we want.
Here's the jQuery script I am using (it's in no-conflict mode so it plays nicely with the other code libraries in wordpress):
Code:
var $j = jQuery.noConflict();
$j(function(){
$j(document).ready(function( ) {
[code]....
how I can make a 'description text box' disappear/fadeout when another one gets clicked? Right now you actually have to go back and re-click each one before it toggles OFF, which starts looking terrible after you've clicked a few of them.
View 7 Replies
View Related
Aug 18, 2005
I have searched high and low for this topic and can't find it anywhere. I have an administration form that lists tasks for an admin. For each item on the task list I want to offer the admins a button that will dynamically show a form within the page and just under the task item (without sending the page back to the server at this point). When the button is clicked I want the text on the button to change from "Click here to add comments" to "Close this form". I also want any open form to close if another 'open form button' is pressed.
I am still not that strong in JavaScript and DOM. I am not necessarily looking for some to do this for me, but I would like at least a starting point. I have found a small snippet that uses an image as the trigger for the event, but I would like to use a button to stay consistent with the look and feel of the page.
View 6 Replies
View Related
Jun 2, 2010
I'm trying to toggle the on and off class on list items but having issues it working.
I only want the 'on' class on the element that is clicked. So if another element in the list is clicked it removes the 'on' class from the one that had it to the one that has been clicked.
$(document).ready(function(){
View 1 Replies
View Related
Jun 17, 2011
I have a nested lists which contain city names, and then level 2 is businesses in that city. those are hidden by default so that when you click on the city name the businesses will slideToggle down. What would be the correct script to enable this.I have the effect working, but when I click on any of my top level anchors all of the nested items toggle. I want each city's businesses to act independently from each other.
see example below
<ul id="cityList">
<li><i>Albuquerque</i>
<ul class="city">
<li><a class="parkTitle" href="#">American RV Park</a>
[code]....
Here is the script i currently have
$('ul.city li a.parkTitle').click(function(event){
event.preventDefault();
$('.parkInfo').slideToggle();
});
example when I click on "american rv park" the div "parkInfo" directly below that first link would toggle
View 1 Replies
View Related
Jul 15, 2009
I have just started out in jquery and thought it would be cool to add some effects to my football clubs site.
I have a players page with a list of players. In the past each player link would open a new individual profile page. This was not ideal.
Now i want to create a list of players names that show a small bio below their names when their link is clicked.
I have created some code but it just shows the bio of all players when a link is clicked. There are lots of links so repeating all the code with unique id's i believe is not the best solution.[code]...
View 1 Replies
View Related
Jan 9, 2009
Was wondering how to accomplish this.I have several table rows that I would like to hide all with the push of a button.For instance:
Code:
<tr id="objects_row1"><table class="apples">
<tr id="apples_row1"><td>asdf</td></tr>
[code].....
View 4 Replies
View Related
Jul 23, 2005
As I can remember this is not allowed in Java:
int x, y, z;
switch(x,y,z){
case 1,2,3:
System.out.println("Hep");
break;
}
But what about in JavaScript, or are there some other kind og syntax for switch?
View 2 Replies
View Related
Mar 20, 2011
As a JS rookie I've managed to toggle specific backgrounds on multiple mouseovers. The code below does exactly what I want, but I'm not quite satisfied with the way it's done.The definite webpage will contain a lot of projectboxes, and for each project I need to add two functions in my script. Not very efficient. I'm looking for a single function which works in the same way, preferably making use of an array where I can add new projectimages.
View 1 Replies
View Related
Nov 9, 2010
I have a table containing multiple rows (tr), each row has two columns (td). In the first columnIhave acheckbox, when this checkbox is clicked i need it to change the class of a div in the second column of the row.
[Code]...
View 2 Replies
View Related
Sep 23, 2008
I would like to do a switch in javascript, with multiple values in the case. code...
View 14 Replies
View Related
Oct 14, 2010
I'm trying to have multiple divs with the same class acting a s a button. I need to handle the click for each one. I will be obtaining the name attribute and passing that in an ajax call.However, this only works for one of the divs on the page, am I doing something wrong?
$(document).ready(function(){
$('#mark_sold').click(function() {
var item = $(this).attr("name");
alert(item+'clicked');
});
});
I'm also going to need to know how to refresh an image, too. I will be updating an image in the ajax call.
View 2 Replies
View Related
Dec 10, 2010
When my page loads I want some text to fade in on my header, display for a few seconds, thenfade out, followed by a second piece of text which does the same, then a third etc. Ideally, I would like all the text elements to loop infinitely. I have managed to get the effect I want with one piece of text usingthese simple lines of code but am stumped when it comes to the subsequent ones. From what my small brain has computed I think the option may be to put all my text items in a list, set the initial list div to display: nonethen apply the fadein, display, fadeout to each in turn. But I don't know what I would put in the script to acheive this (create some sort of array with the li items?)
My searches keep leading me to image carousels etc which I couldn't work out how to configure for text. Also I'm not sure if the (hidden) list would just be dropped onto the page for non-javascipt enabled browsers messing up my page layout, so maybe I need to pull the text from a file / folder?
<script type="text/javascript">
$(function() {
$('#hdrtext').fadeIn(5000);
});
</script>
<div id="hdrtext">
first line of text
</div>
View 2 Replies
View Related
Apr 24, 2011
I have a function called blink:
function blink(strObject) {
$(strObject).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
[code]....
View 1 Replies
View Related
May 13, 2009
I need to append multiple spans to the line items in an unordered list. Essentially, each line item contains a <span> and I need to grab the content of that span and append it to the bottom of the line item it's contained in. Here's what I have so far: My jquery code:
$("ul").ready(function(){
var Name = $(".name") .text();
var Content = $(".content") .text();
[code].....
As you can see, instead of taking the all the "Name" var's and putting them together, instead of just using the "Name" var of that line item.
View 1 Replies
View Related
Feb 5, 2010
I have an image next to a checkbox and if either of them are clicked I want to run the same function. I've tried these so far
[Code]...
View 3 Replies
View Related
Feb 28, 2010
[code]I want to be able to highlight all of the divs which contain both the classes 'two' and 'three'. So the first and the third divs above are highlighted but the second isn't because it doesn't contiain both classes.I can see how to select multiple classes like this:$('.two, .three').css('background',''yellow');This selects items with either'two' or 'three' classes. I want it only to select the items with both classes.
View 1 Replies
View Related
Sep 7, 2010
I know this does not work, but hopefully you can see what I am trying to do. Only the first value is tested, but I want all of them to be.
[Code]...
Pretend there are like 10 more cases with more numbers with them. Currently this will only text to see if x is 0 or 42. How do I get it to test for the other numbers?
View 7 Replies
View Related
Mar 9, 2010
I have some jQuery code to add and remove a class to toggle an image. It works for one but now I want it to work if I add other checkboxes. Currently all the checkboxes change the 1st div. I would like to make it toggle it's respective div.
<html>
<head>
<title>jquery to Show/Hide a Div</title>
<script type="text/javascript" src="[URL]"></script>
<script type="text/javascript">
$(document).ready(function(){
$("input").removeAttr("checked");
$("input").click(function(){ .....
View 1 Replies
View Related
Mar 9, 2010
I have some jQuery code to add and remove a class to toggle an image. It works for one but now I want it to work if I add other checkboxes. Currently all the checkboxes change the 1st div. I would like to make it toggle it's respective div.
<html>
<head>
<title>jquery to Show/Hide a Div</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
[Code].....
View 2 Replies
View Related
Dec 18, 2011
I am trying to toggle multiple divs toggle open/closed show/hide with a slide left effect It works but is buggy if you click too fast [URL] I want to create this but control to content in the sliding divs [URL]
View 1 Replies
View Related
May 12, 2010
Trying to get this to work individually with each individual instance on the page (usually 5-10 questions on each page)Right now it adds the class to every instance of the div that has the answerCorrect class. need the link to only turn on the specific answer associated with it.
<script type="text/javascript">
$(document).ready(function(){
$(".showAnswer").click(function(){
[code]....
View 3 Replies
View Related
Mar 13, 2010
If you look at this page [url] you will see that if you hover over the photo the text block goes up, and if you hover over the text it slides down and covers the photo. It's all pretty basic and it works fine. But ones I try to get them animated during the sliding up and down the trouble starts.
It works fine if you take the time and wait for them to go back to their starting position, but if you move over the items quickly it becomes a mess. You can see what I mean on this page [url]
I hoped that by adding a stop() before the animation if would fix the problem, but it doesn't really improve at all. It still quickly becomes a mess if you hover from one item to the next one.
How I could get the animations to work properly without it becoming a mess? I now there are double id's in the html, but unfortunately I can't really change the html.
View 1 Replies
View Related
Feb 8, 2011
I have a simple filmstrip that uses getJSON to return data. The data is an array containing two arrays. The first, is the base path to photos. The second is a list of the photo file names. I am trying to loop through the array of photos and set them in divs. Then I need to attach an event to popup a larger view of the image placed in a dynamically generated div containing the image and initially hidden.
So what I am trying to accomplish is:
1. get JSON data from server.
2. get base image path from json data array
3. get list of images from json data array
4. Loop through list of images, prepend base path and assign to hard coded div.
5. create a dynamically generated div with larger version of same image.
6. Attach hover action to cause a mouse-over action on the hard coded div to popup the dynamically generated div containing the larger version of the image.
My issue is that once my code runs, no matter what image in the filmstrip I mouse over I always get a popup with the last image in it. Here is my code:
<script language="javascript">
$(document).ready(
function(){
$.getJSON("<?php echo site_url('filmstrip/index');?>",
function(data){
var dir = data['dir'];
var imgs = data['imgs'];
var i =0; .....
View 3 Replies
View Related