Jquery show hide multiple divs independently

pity, that now can not express..

Jquery show hide multiple divs independently

I am new to jquery and need some help with this I have the following simplified html [Code] 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.

I've got a PHP while loop spitting out an article title and it's content from a database and I have links to show or hide the content of the article under each title. I want to show and hide the content of the article selected as you'd expect. It works well!

Show/Hide Multiple Divs with Jquery

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,ticket I am using a class name for the divs but the name is generated by a field have set in my database. I've got an issue with the attached file.

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. 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. 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.

jQuery Tutorial - 47 - Hide/Show a DIV

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. 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. 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] How this code can be amended to use multiple drop downs within one form?

Does anyone know how this code can be amended to use multiple drop downs within one form? I am trying to adding cookies to this script. I am going to achieve something like this.Some time ago I have written a tutorial in which I described how to toggle show and hide an area or a DIV container with JavaScript by clicking a link. In the comments, the question arose how it is possible not only to open a new DIV but also to automatically close the previously opened other DIVs at the same time.

I would like to answer this question today in form of this tutorial. First, when loading the page, only the first container should be visible, the other two are invisible. All boxes that will later work as toggle-links have been given the class "copen".

The containers, which should later can be opened and closed with clicking those links, all have the class "c". In addition, the containers to be opened all received a unique ID c1, c2 and c3which are linked to the associated link via the attribute "data-c". By JavaScript, we now only need to assign the open and close function to all links.

2008 mazda bt 50 wiring diagram hd quality martin

First, we close all previously opened containers. Of course, since we do not want to write a separate function for every link, we have stored the ID of the respective associated container in the data-c attribute. Then we just have to call. Of course, this simple example can be extended arbitrarily.

Additional containers can be easily added by adding more IDs according to the same pattern. If you want to operate several groups simultaneously on the same page, which can be opened and closed independently of each other, you have to select a separate class apart from "c" for each group and make sure that no ID is assigned twice.

You can find Software by Stefan Trost on sttmedia. Do you need an individual software solution according to your needs? Please note: The contributions published on askingbox. They are not verified by independents and do not necessarily reflect the opinion of askingbox. Learn more. Ask your own question or write your own articles on askingbox. How to do. Reply Positive Negative.

Participate Login Register Ask Question.

Lebanon court docket

Info User Top Donate Deutsch. About About us Contact Advertise here.Hiding a single element with Jquery was pretty straightforward.

Jquery: show/hide multiple elements independently

Thanks to Justin Young for requesting this new function and getting me to do something useful. As before, the aim was to make portable, accessible code. All that's needed for the script to work is to give any element an entire div, a paragraph, whatever a CSS class of "toggle". The preceding element i. This seemed like a good approach, and works especially well with sections marked up with headings. Links and other child elements will work fine too.

A single paragraph can be hidden by giving it a class of toggle too. I can't help but be impressed by how easy it is to use jquery - even for someone with limited programming and javascript experience like me.

Script writing for television ppt

Again, the preceding element is a heading. Hi there. This is an excellent script. However, is it possible to modify the script so that the previous text is hidden when the next one is shown, more like the way an accordion works?

The accordion unfolds as expected, but if I click on 'hide', the text doesn't hide but the toggle text just changes to 'show' Andy, this script is exactly what I have been looking for. I am having a problem using images as the toggle links, however. Everything works great until clicking the "hide" image. The elements toggle correctly, but the original "show" image does not return "hide" image persists. I think this is the same issue CA had.

Am I doing something wrong? Sunil K. This is really great I am using this script to navigate certain links and is overlaping a form. The accordion still works, but the hideText link fails to change. I only find this issue in Internet Explorer 8 it well could be in older versions. Firefox works perfectly. One bug I found with Safari is that when the element with the class "toggle" is animating into view, it pushes my page layout horizontally, making the horizontal scroll bar appear for a few milliseconds.

Still, this is an awesome script that is much easier to use and much more accessible than others I've seen. Sorry to be posting what I imagine to be a fairly basic question. How can the script be modified to avoid this - presumably detecting where the togglelink class has already been appended. Thanks for the instructions. Hard to describe, but the following fix should tell something.

Gabriel Lora. I am having problems with this script.Sponsored by and others. Copy code. Please tell us why you want to mark the subject as inappropriate.

Maximum characters. Report Inappropriate Cancel. From : guest. Content :. Type the characters you see in the picture below.

jquery show hide multiple divs independently

Send Cancel. Subject :. Send Update Cancel. Email ID. Attach files. Desktop Google Docs. Each Attachment size should not exceed 1.

Max no of attachments : 3. Loading User Profile Response title. Publish Back to edit Cancel. Sign In. New to this Portal? Click here to Sign up.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

jQuery: Show a DIV - Hide other DIVs

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I want to make a collapsible DIV like this: If you click on the picture which is in the table and comes with show class the hidden div slides down the one with the content class with it's content and if you click on the hide button or anywhere else on the page, the content div will slide up. I want to use multiple tables and hidden divs on the page with the same classes so i want to make sure to open them independently.

Here is my JSFiddle document, hope that someone can help. Thanks in advance! Learn more. Asked 3 years, 11 months ago. Active 3 years, 11 months ago. Viewed 4k times.

Sorry, i changed it! Active Oldest Votes. Pietro Pietro 8 8 silver badges 17 17 bronze badges. Thank you! It worked! Could you help me with the click-anywhere-to-close problem?

jquery show hide multiple divs independently

It's not working! Pietro Could you help with the last comment? One more thing Pietro: i don't want to close the the content DIV if i click inside just if i click outside of the box.

How could i achieve this? Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Email Required, but never shown.

jquery show hide multiple divs independently

The Overflow Blog. Podcast Programming tutorials can be a real drag. Featured on Meta.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here.

Dcs multiplayer chat

Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. So far, the jquery code I have will show the div clicked, but the hide part wont work.

Learn more. Asked 7 years, 1 month ago. Active 7 years, 1 month ago. Viewed times. BeardFist 7, 3 3 gold badges 30 30 silver badges 38 38 bronze badges. Die 20 Die 20 1 1 gold badge 5 5 silver badges 16 16 bronze badges. Active Oldest Votes. OJay OJay 4, 2 2 gold badges 19 19 silver badges 36 36 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.

jquery show hide multiple divs independently

The Overflow Blog. Podcast Programming tutorials can be a real drag. Featured on Meta. Community and Moderator guidelines for escalating issues via new responseā€¦.

Feedback on Q2 Community Roadmap. Technical site integration observational experiment live on Stack Overflow. Dark Mode Beta - help us root out low-contrast and un-converted bits.The page will initially show all divs. The idea then is that there will be a button to reset show all and then separate buttons to show a particular div while hiding the rest. You can make this more generic, and use the obvious convention - the button and the div with the same number in the id are related.

I had this same problem, read this post, but ended building this solution that selects the divs dynamically by fetching the ID from a custom class on the href using JQuery's attr function. If they fall into logical groups, I would probably go with the class approach already listed here.

Many people seem to forget that you can actually select several items by id in the same jQuery selectoras well:. Just a small side-note Just replace it with jQuery and you're good. Any help would be much appreciated. Assign each div a class. Add table row in jQuery How do I check if an element is hidden in jQuery?

Creating a div element in jQuery How to check whether a checkbox is checked in jQuery? How can I select an element with multiple classes in jQuery?


Taulmaran

thoughts on “Jquery show hide multiple divs independently

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top