JQuery :: Swap The Content Within A Div Without Affecting The Other Divs With The Same Class?
May 28, 2010
I have a listing of items on the page and each one has a <div> with a description in it. There are two versions of each description, one short and one full length. I like the user to be able to swap between them by clicking the 'more' and 'close' links. The problem with what I wrote is that it applies to all the divs on the page instead of the specific one that was clicked. What can I change to correct it?
The jQuery:
$(document).ready(function() {
$('div.desc > p.desc-full').hide();
$('a.more').click(function() {
$('div.desc > p.desc-trunc').slideUp('fast');
[Code].....
View 1 Replies
ADVERTISEMENT
Sep 19, 2010
When I mouseover over the list items below, I would like a DIV that I specify (in this case corresponding by number - but I would like the flexibility to define the div name individually if numbers don't exist, or don't match up [I'm using Drupal, and everything is dynamically generated]) to slide out, or just appear, beneath it (the list will be inline). It needs to stay open so people can click the link that appears in the DIV, but when you mouseout from the DIV or the list item, the div needs to disappear.
My HTML looks more like this:
<div
id
=
"navigation"
[Code]....
I'm not familiar with how this code is working, and have been trying to work it out, but I'm not sure I understand the use of "idx" and how the singular "slide" term comes into play.
View 1 Replies
View Related
Sep 10, 2011
I am trying to roll out a 24 hour event, where at the top of every hour one div is swapped out for another. The code I'm using is:
onload=function(){
var rightNow = new Date();
var day = rightNow.getDay();
var hour = rightNow.getHours();
[Code].....
But, it only works with two instances of it...for two divs. If I put the code in three or more times, to swap out 3 or more divs, it doesn't work.
I'm thinking I should be able to write everything into one block of code, but can't figure it out. Any suggestions? I'm sorry to bother people with this, I just can't find any info online and I want to test it out ASAP so I know if I have to abandon the effort and try something else. I would just like to avoid having to build it in Flash too.
View 2 Replies
View Related
Mar 1, 2010
Currently I'm using this code:
$(document).ready(function(){
//when a link inside our thumbba div is clicked
$('#thumbb a').click(function(event){
//prevent the default behavior(going to the page)
[Code]....
to swap out content from a hidden div (swap-b) into the visible div (swap-a) - this works great, however, I have 12 of these "hidden" divs on the page, and I want each one to behave independently. Currently, when I click the swap button for one div, it activates all the others. I get that this is because all the divs have the same IDs, and that the function is telling all the divs to behave the same, however, I don't see how I'm supposed to apply this function to each div independently. I've tried using a "this" function to make it work, however that just breaks the function.
View 12 Replies
View Related
Jun 15, 2011
I'm trying to swap the class of an element when it's clicked on. Using jquery 1.6.1, here's what it looks like:
[Code]....
Now, for the sake of brevity�*i omitted some other stuff that is happening when they're clicked on. The problem is that the click event for .unchecked_container is firing fine and the class is changed, BUT when clicked on again�*the '.checked_container' click event is NOT firing.
View 1 Replies
View Related
Feb 2, 2011
I am attempting to make a menu that has a background image that changeswhen you rollover or click a menuitem. I've got the hover effect working fine with CSS, but am trying to implement the click event via jquery with the following:
CSS:
div.SustainResourcesMenuTabs
{ background-image: url('/images/departments/commdev/sustainability/menu_tab.jpg');
}[code]....
My process is to reset the entire menu to the inactive state, then switch on the active state for the item that was clicked. Eventually, the item that was clicked will display its corresponding body section as well. I've tried using the CSS pseudo-class "active", but since the entire div is the link, that is unavailable. I've also tried multiple variations of addClass/removeClass, toggleClass, and setAttribute/removeAttributebut nothing hasworked so far.
View 2 Replies
View Related
Jun 3, 2010
I have a large div with a Google Map and a much smaller div with Google Streetview. I want the user to be able to click a button and make the large div show the street view and the small div show the map. I'm hoping jQuery can be used to make this 'easy' somehow?
I just don't know how to approach this ..
1) Resize the divs and change z-order?
2) Swap the id of the divs and somehow trigger a refresh?
3) Swap the html using jquery?
View 3 Replies
View Related
Oct 18, 2007
I'm trying to get the header cells of a table to do simple rollovers. But as you can imagine microcrap isn't wanting to play nice with IE.
<td class="table-header" onmouseover="this.className='tablesortable'" onmouseout="this.className='table-header'">
With IE 7 you don't get the class to work. It swaps out the first class but doesn't add the onmouseover class. Am i missing something here or is this just another reason to hate IE?
View 4 Replies
View Related
Mar 23, 2011
This is what I'm trying to do: I want a simple image container to swap the image inside it by clicking the nav buttons on the right like 1, 2, 3.Here's my code:
HTML
Code HTML4Strict:
<div id="item1">
<div class="img-container shadow" style="background-image:url(images/gallery/tcg1.jpg)">[code].....
My jQuery code is not right. I want it to turn off the "hover" class and the "show" class of the others when you click one. I think I need some kind of if..else? how to write it? I have a bg image set on the container div so there's an initial image to view.I also need multiple of these on the same page!
View 1 Replies
View Related
Mar 2, 2009
I am trying to getelementbyclass and than on click change the displaytype or change to use another class for that div.Below is what I have so far, but I can't get the div style to change based on getelementbyclass.On click I would like to change the targeted div to use .show class and all others still to use .hide class.Any way to do this? Am I close?
Code:
<script type="text/javascript">
function showHideAll(id) {
[code]....
View 2 Replies
View Related
Apr 28, 2011
I have a div with a height of 100 pixels.If the content is too much to fit in div, I want to show a 'Read More' link at the bottom.If you then click 'Read More', the div expands to full height so all the content can be seen and the link text changes to 'Read Less'.If you then click 'Read Less', the div contracts back to 100 pixels.I've found solutions that can handle the above situation, but I want to have multiple divs with the same class that all work independantly of each other.So I'd have the following HTML
[code]
<div class="openclose">
...some content...
[code]....
View 3 Replies
View Related
Jul 26, 2010
I need to add a class to every div (with ID #myDiv) NOT containing an <li>-Tag.
I have:
Line 5 doesn't add the class to the div.
View 6 Replies
View Related
Dec 19, 2010
URL..when you hover over an image, I've used .hover to fadeIn a DIV called 'zoomicon' for that image, but my problem is that when you hover one image, not only does the zoomicon for that image fade in, but all instances of zoomicon fade in, as well as fade out.how do Iseparateinstances of zoomicon to fade in and fade out for their respective image blocks?[code]
View 3 Replies
View Related
Dec 1, 2010
I have a bunch of dynamically created divs which I need to loop through and then display text inside which is obtained via AJAX.
<div class="appStatus" id="appStat_1>TEXT FROM PHP PAGE</div>
<div class="appStatus" id="appStat_2>TEXT FROM PHP PAGE</div>
<div class="appStatus" id="appStat_3>TEXT FROM PHP PAGE</div>
Basically, I want to loop through all divs where class = appStatus and on each iteration pull data from a PHP page (via AJAX) to display in the DIV. I need to send the value after the _ of the id (which I can obtain using substring) with the AJAX request in order to return the correct text.For some reason.I know that I need to do something with
$("div.appStatus").each(function() {
)};
Just got myself lost in everything I tried.
View 2 Replies
View Related
Apr 2, 2009
For some reason, when my first div loads, I'm seeing all 3 text show up even though they're in different <div> containers:
<script type="text/javascript">
$(document).ready(function() {
$('#Tabs').tabs({ fx: { opacity: 'toggle'} });
});
[Code].....
Here's a print screen: [URL] so you can see that for some reason all of that text is showing up at the same time. Do I need to hide the other divs first? I even tried that with adding $('#Tabs div0').hide(); // Hide all divs but it did not help. I would assume out of the box, it would hide the rest of the divs for me and only show the default first.
View 1 Replies
View Related
Feb 25, 2011
I'm trying to debug a tabbed menu implementation, where I have a variety of pages that are made visible based on tab clicks. This works well, until I have a page that is laid out with nested divs. Any content beyond the child of the selected page (page_about shows 'Put an image here' but not 'This is where...') remains invisible. I've tried a number of options in the slideDown statement, but failed thus far.
[Code]...
View 1 Replies
View Related
Aug 3, 2009
I am wondering how to select a div on a page that is loaded using the .load() function.I have tried using a function in the callback of the page to select elements but this didn't work.It appears the pages are called after a the document has loaded (which makes sense) thus anything I place on the page that is loading the various data into the the content div can't selected the newly loaded content.I could include the new script on the pages I am loading but this would result in the undesirable editing every page I have made.
View 6 Replies
View Related
Apr 17, 2011
how can i use .load() or .get() to load external content into div?
i have code below but doesnt work? i dont know what is the problem.
$(document).ready (function(){
$("tabs1").click(function(){
$("content").load("about.php");
});
});
View 3 Replies
View Related
Jun 16, 2003
When the page loads I want it to go through a certain function for every div of a certain class.
View 7 Replies
View Related
Jun 4, 2011
I couldn't find any in Google or in the JQuery plugin library.I am trying to develop a book like app, where the site manage enters a text as long as he like into CKEditor textbox. the editor of course create tags around the text, and also there might be images inside the text.Then when someone chooses the book (bunch of DIV tags), he gets a book like js (this is working) and i need to populate the book with the content from the DB.
The problem is that i just can't figure a way to split the text into small chunks without destroying tags in the process.Is there a split app in jquery that does that?
View 2 Replies
View Related
Mar 2, 2010
I am currently using load() to display content upon clicking a line. I would like to add another load function to the same anchor's click event. I tried applying the click function to the sam a.class but it did not work.I have the load a.class within an accordion. here is my current jQuerry functions on the page
$(document).ready(function() {
//ACCORDION BUTTON ACTION $('div.accBtn').click(function() {
$('div.accContent').slideUp('normal'); $(this).next().slideDown('normal');
});
[code]....
View 6 Replies
View Related
Jun 8, 2011
This is my current script
<script type="text/javascript">
$(document).ready(function(){
$("div.content1").load("content_1.txt");
$("div.content2").load("content_2.txt");
[Code].....
What I'm trying to do is get the script to look for class names div.content"x" and then correctly load content_"x".txt
View 4 Replies
View Related
Oct 23, 2010
I have this demo site here [URL] It's a simple div with overflow: hidden this containing div houses 3 divs each containing different content. The nav at the top scrolls the divs to show the div relating to the nav clicked. The problem I have is with the last btn - Planes. The div containing the planes photos doesn't scroll to the top of the containing div but sits at the bottom. The first two btns. work as expected so I don't understand why the last btn doesn't.
[Code]....
View 2 Replies
View Related
Oct 25, 2010
I want to count the amount of divs on a page with the class of "samplesSection".
HTML
<html>
<head>
[code]....
When you click on "Click", it alerts you with how many divs with class "sampleSections" exist. Here's the problem: When it loads, just click "Click". It alerts 1 - valid. Then click "Category", AJAX refreshes, click "Click" and it alerts 2 - valid again. Click "Client", AJAX refreshes, and click alerts 3 - valid once more. However, whenever I click back on any of the other categories, it always alerts 3.
View 1 Replies
View Related
Aug 23, 2011
I have the situation where in the first instance I would like all divs to be visible.
Only when the user selects something in a select menu the non selected divs will hide.
I have the following:
Code:
<select name="type">
<option value="ShowAll">1</option>
<option value="Selection1">1</option>
<option value="Selection2">2</option>
[Code].....
So, if the user were to select "Selection1" two divs should only be visible. The same will apply for others, if "selection4" is made then only one div would be visible.
The user will need to the option to reset and display all divs by using the "ShowAll" selector.
I ahve seen examples of this on the net however, they do not show all the divs in the first instance and they are donhe by ID and not class. I need to do it by class as I have some with the same name and they cannot change.
View 5 Replies
View Related
Jan 22, 2010
The very basic onclick code I threw together:
function descw()
{
document.getElementById("desc").style.display="block";
}
function descc()
[Code]...
This works, but I have a whole class of divs named select that need their own individual description divs. Id method is okay for one div apparently, but if I click on others it loads the first description div. What do I use instead? I tried getElementsByName and Atrribute and got an error.
View 16 Replies
View Related