JQuery :: Hide Multiple DIVs - Two Classes For One Element?

May 21, 2010

I made this small piece of code, and I think I made it in a very drawn out way. I am sure there is a lot quicker way to do it. I want all divs to be cleared that are in a certain div. So when one link is clicked, the visible div is replaced with the new one (depending on the link)

Here is the code I have done...
$(document).ready(function(){
$(".untitled1link").click(function(){
$('.untitled1, .untitled2, .untitled3, .untitled4, .untitled5_1, .untitled5_2, .untitled5_3, .wall, .lightswitch, .detritus, .untitled6, .table, .socket, .socket2').hide();
$(".untitled1").fadeIn('5');
});
});

I just need a way to say clear all in that certain div, rather than having to name each class. I was thinking of giving each of those another class which is uniform across them all. But I don't think you can have two classes.

View 2 Replies


ADVERTISEMENT

JQuery :: Add Show And Hide Behaviour To Multiple Classes

Nov 9, 2010

adding my show and hide behavior across various classes, so the message shown will be unique to the class.

My J-Query looks like this;

<script type="text/javascript">
$(document).ready(function() {
$('#One').hide(); /
$('.col2').hover(

[Code]....

I have include a demo that should make it clearer, as to what I want to achieve. Ideally, each box will show a unique overlayed message as the user's mouse enters the box and hide once the mouse leaves.

View 2 Replies View Related

JQuery :: Get First Element When There Are Multiple Classes

Jun 16, 2009

How do you get the first element when the element got multiple classes?

View 6 Replies View Related

JQuery :: Pull One Class From An Element With Multiple Classes

Jan 17, 2011

This can't be too hard, but I'm not seeing the answer. Elements on a web page may contain a class starting with "tr_". Sample HTML:I'm using the following to select matching elements: $('[class*=tr_]').each(function() So far so good. But now, I need to get the name of the class that starts with "tr_" from each matching element.

View 2 Replies View Related

JQuery :: Store In Variable Only First / Only Second Of Element's Multiple Classes

Apr 22, 2010

I'm using this bit of jQ to add a class to two different elements based on the class of another (parent/grandparent, etc) element.

First, when there's no class at all in <div id="main-content">, the 'active' class is added to *all* the #nav-primary LIs, and also to *all* the #aux-left DIVs; how can I modify this so that in the absence of any class on #main-content, do nothing?

Second, how can I target only the first or second of multiple classes to store in the 'containerClass' variable, e.g., <div id="main-content" class="apples bananas">?

View 2 Replies View Related

JQuery :: Show/Hide Divs For Multiple Selects?

Mar 25, 2011

I have a jquery function that will show or hide a div id="hide1" based on the result of a select id="ticket1"

$(document).ready(function(){
$('#hide1').hide();
$('#ticket1').change(function(){
if(this.value == 'adult'){$('#hide1').hide();}

[Code]....

It works well! But my script actually clones elements of the form so a user could be selecting adult or child for a number of tickets - ticket1,ticket2,ticket3....

How can I adapt that script so that it will show/hide for each ticket

View 4 Replies View Related

JQuery :: Show / Hide Multiple DIVs On Page?

Jul 11, 2011

I have a little issue with trying to hide / show multiple divs on my page. I am using a class name for the divs but the name is generated by a field have set in my database. So for example
<div class="General">Ttitle 1</div>
<div class="General">Ttitle 2</div>
<div class="General">Ttitle 3</div>
<!-- and my link is -->
<a href="#" class="toggle" title="General">Toggle 1</a>

And then say I have
<div class="Questions">Ttitle 1</div>
<div class="
Questions ">Ttitle 2</div>
<div class="
Questions ">Ttitle 3</div>
<!-- and my link is --><a href="#" class="toggle" title="
Questions ">Toggle 2</a>

What would be the easiest way or the best way to code out the jquery to hide / show all the divs with the same name as the links title i can do code jquery to toggle 1 div but not sure how to code it so that it will hide / show all the divs with the same class name.

View 5 Replies View Related

JQuery :: Show/hide Multiple Divs Independently?

Mar 28, 2010

Is there a way I can simplify my code below? I want to be able to have just one iteration of the code and have it automatically switch out the IDs without have to add a new bit of JavaScript with each new div that is added. Here's my Javascript:

$(document).ready(function() {
// toggles the personnel window on clicking the image/header
$('div.title'+'#one').click(function() {

[code]....

View 2 Replies View Related

JQuery :: Show Hide Multiple Divs Independently Without #ID?

Dec 5, 2009

I am new to jquery and need some help with this I have the following simplified html

[Code]...

View 2 Replies View Related

JQuery :: Hide / Show Multiple Divs From Anchor Tags?

May 3, 2011

I've got an issue with the attached file.

I have 3 buttons & 3 divs.

I would like to hide/show the relevant divs (into a container) based upon the button pressed. If no div was open, then it would simply open the relevant div, however if say div 2 was open and div 3 was pressed, div 2 would toggle closed then div 3 would toggle open.

I've got each individual div opening and closing, but I'm stuck at the next point (checking if a div is open/toggling etc).

View 5 Replies View Related

Easier Way To Hide Multiple Spans/divs?

Jul 20, 2005

I have a js script that changes the visibilty of a selected span to "visible", but makes sure that no other related spans are visibile to the user by hiding everything first....

View 1 Replies View Related

Show/Hide Toggle On Multiple Divs?

Oct 24, 2010

On the homepage of my site, I would like to have some nav links that toggle between a few divs that are below in the content The divs in the content should display one at a time. For example, if you click nav1, the user would see div1. If nav2 is then clicked, div1 would hide and div2 would display.

I have some code that will do this, but for some reason it is hiding any divs that are within the toggled div. I'm very basic with JS and could use some help here. Here is my code:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
function toggleID(IDS) {
var area = document.getElementById('secondContent');
var sel = area.getElementsByTagName('div');

[Code]...

View 1 Replies View Related

Script To Show & Hide Multiple Divs?

Jul 6, 2011

I found the following script online to show/hide a login div.

<script language="JavaScript" type="text/javascript">
function login(showhide){
if(showhide == "show"){
document.getElementById('popupbox').style.visibility="visible";
}else if(showhide == "hide"){

[Code]...

It works really well but I have other div I would also like to show/hide. Is it possible to have a variable in the function that I could pass the name of the div to show/hide.

I have a ul list that I am using for a navigation menu and I would like to be able to click on items in the list to show different div's. I assume this is possible, so could someone please give me an indication of how to do it as I have been trying for a few days now and no joy.

View 5 Replies View Related

Multiple DIVs Toggle Show/Hide?

Dec 7, 2010

Complete JS first timer here, hope you all can understand my difficulties and stupidities without getting too frustrated. Trying to make a portfolio website as a Christmas gift. Anyway, I'm trying to build a menu that:

1. Expands/Retracts when clicking on other 'headers' in the Menu.
2. Allows for more than one object to be listed in each 'header'.

(Something similar to this [URl]... I've tried to hatch together several online solutions but I really have no idea what I'm doing, as you can see:

[Code]...

View 1 Replies View Related

Multiple Dropdowns With Show / Hide DIVs

Aug 11, 2010

I am using the following code to show / hide form elements within a div based upon the drop down choice. How this code can be amended to use multiple drop downs within one form?


HTML Code:
<html><head>
<title>Show and Hide</title>
<script>
// Function that Shows an HTML element
function showDiv(divID){
var div = document.getElementById(divID);
div.style.display = ""; //display div
}

// Function that Hides an HTML element
function hideDiv(divID){
var div = document.getElementById(divID);
div.style.display = "none"; // hide
} .....

View 6 Replies View Related

Multiple Drop Downs With Show / Hide Divs?

Aug 11, 2010

I am using the following code to show / hide form elements within a div based upon the drop down choice. Does anyone know how this code can be amended to use multiple drop downs within one form?

<html>
<head>
<title>Show and Hide</title>
<script>

[Code]...

View 1 Replies View Related

Show And Hide Multiple DIVs On Page - Add Cookies?

Jul 12, 2009

I use this script to show/hide multple divs on a page. I am trying to adding cookies to this script.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]"><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Show Hide</title>
<script language=javascript type='text/javascript'>
function hideSpan(pass) {
var spans = document.getElementsByTagName('span');
for(i=0;i<spans.length;i++){
if(spans[i].id.match(pass)&&spans[i].style.visibility){
spans[i].style.visibility=spans[i].style.visibility=="hidden"?"visible":"hidden";
}}}
</script></head><body>
<span id="256a" style="visibility:hidden;" >
My content<br/>
</span><span id="256b" style="visibility:hidden;">
<br/></span>
<span id="512a" style="visibility:hidden;">
<br/></span>
<a href="javascript:hideSpan('256')">show/hide span 256</a>
<a href="javascript:hideSpan('512')">show/hide span 512</a>
</body></html>

View 3 Replies View Related

Show Hide Multiple Divs Based On One Div And Search Text?

Jun 14, 2011

I am going to achieve something like this.

<div id="sidebar">
<div id="html1"><h2>Test 1</h2></div>
<div id="html2"><h2>a1 tes2</h2></div>
<div id="html3"><h2>a2 tes3</h2></div>
</div>

The thing is that first I need to detect if the div id is "sidebar" if its "sidebar" then it will pickup all the text inside h2 tag and will search for a1 or a2 in the text.If a1 is found then it will pickup the id html2 and make this div only visible.So in this case it will pickup id html2 and make it visible while other ids like html1 and html3 will be hidden.

View 2 Replies View Related

JQuery :: Show Two Separate Divs, Hide Divs On One Click?

Aug 19, 2009

I'm looking for some javascript to work with wordpress (jQuery preferrably) that will show/hide multiple divs on one click.

I had one working but it was kinda janky because it was causing me to have two divs with the same ID on one page. No good.

Since I updated to wp2.8.3 prior to launch, it's not working. So I've decided to just try and do it right.

Here's a page: [URL]

So, what I want to happen: On page load, the first tab: "general" and it's corresponding div beneath should be showing. And the first image should be showing. The other content divs and images should be hidden. I've given the text content divs a dashed border to show their borders. When a visitor clicks "dine at home" the general div and image hide, the second content div shows, as does the second image (it's currently the identical image, but the client may change later.) Etc.

I'll be using this function on a few other pages as well.

how to adjust this javascript to work on two different IDs at once?

current code:

Code:
<script type="text/javascript" charset="utf-8">
$(function () {
var tabContainers = $('div.imgswap > div');

[Code]....

View 2 Replies View Related

JQuery :: Hover And Multiple Divs - All Hidden Divs Are Shown, Not Just The One That Supposed To?

Oct 14, 2010

I have been trying to do some tooltips for a website and desperately wanted to learn something new and do that with jQuery.However, every time a mouse hovers over a tooltip, all hidden divs are shown, not just the one that supposed to. Here's my html:

Code HTML4Strict:
<div class="tip">
<a href="#"></a>[code].....

View 2 Replies View Related

JQuery :: Create Paragraphs With Multiple Classes

Sep 7, 2011

It works fine when I give the paragraph a single class name, but when I attempt to create multiple class names the 2nd class name is not created.This is the (erroneous) markup that is created :<p class="class1" class2= "">test</p>How do I instead create (eg) <p class="class1 class2">test</p>.I know that multiple appends are not efficient but it is just a working example.

View 4 Replies View Related

JQuery :: Select Items With Multiple Classes

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

JQuery :: Get A Specific Class From Several Classes On An Element?

Jan 10, 2011

I have a div with several classes on, like this:

<div class="class-one class-two special-class"></div>

I want to get the class that starts with 'special' and store it in a variable...but I am having trouble doing this...I can get as far as storing all of the classes in a variable:

var myClasses = $(this).attr('class');

...but I now need to extract just the one class that starts with 'special'...

View 4 Replies View Related

JQuery :: Return Element Wrapper As Classes/Ids?

May 24, 2011

I am fairly decent with JQuery, but there is always more to learn of course! Consider the following structure.

<div class="container">
<div id="label1">
<div class="label1_1">

[code]....

View 1 Replies View Related

JQuery :: Adding Multiple Classes To ToolTip Functionality

Jan 14, 2012

I am using a JQuery ToolTip on all links with a title="" and it works great. I want to add another class to (.shadow) and it only seems to work with one class.

Here is the code to initialize:

BTW I am using noConflict b/c I am running other JQuery scripts on the page.

I have tried:

And also:

Also tried creating two scripts. One with var $tooltip1 and the other with var tooltip2.

So far nothing has worked.

View 1 Replies View Related

JQuery :: Multiple Classes Selector Causing Trouble?

Sep 19, 2009

In order to allow users to filter content, I've created a small checkbox list. To each checkbox is attached an ID, and too some divs on the page are attached these id's too (in the class attr that is); one div can be attached to multiple id's, and so have multiple classes.

In order to show or hide my div's I wrote :
function couponsVisibles(){
$('.checkInteret').each(function(){
var coche = $(this).attr("checked");
if (coche) {
var idCoupons = $(this).attr("id");
$(".zoneCoupon , div[class='" +idCoupons+ "']").each(function(){
$(this).fadeIn();
});
}});
}
$(".checkInteret").click(function(){
var coche = $(this).attr("checked");
if (!coche) {
var idCoupons = $(this).attr("id");
$(".zoneCoupon , div[class='" +idCoupons+ "']").each(function(){
$(this).fadeOut();
});
}couponsVisibles();
});
It looks like my selector "$(".zoneCoupon , div[class='" +idCoupons+"']")" doesn't work, but I can't figure out why. I've started using the [attribute*=value] selector, but this selector doesn't seem to make a difference beetween class='8 10' and class='8 1'...

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved