JQuery :: Toggle A Ul Depending On The A Href Of A Child Li
Sep 7, 2010
I've been going round in circles on this big time, getting very annoyed, and can't seem to find an answer anywhere. This little bit of jQuery collapses our menu, so that when we roll over, the sub menus float out:
<script type="text/javascript">
function initMenu() {
$('#SideCategoryList ul ul').hide();
$('#SideCategoryList li a').hover(
function() {
$(this).next().slideToggle('slow');
}
);
I have a single page which uses tabs to segment the content. Alongside the tabs themselves is a button for 'Help'. I'd like this button to open a different DIV depending upon the tab that is currently being used.For example, if I am on a tab for 'Ben', if I click the 'Help' button I want the 'helpBen' DIV to slideToggle.If I am on a tab for 'Paul', when I click the 'Help' button I want it to open the 'helpPaul' div.
Some extra needs:
1. switching to a different tab should close the currently open help div (e.g. helpBen or helpPaul)
2. There should only be one help div (e.g. helpBen or helpPaul) open at any one time.
I partly solved this with the following code but with erratic results and I'd like to know what I'm dong so wrong!Here is the HTML for the help button:
<a class="helpTrigger" href="#">Help</a>
The help DIV's are like this:
<div class="helpBen">help relevant to Ben section</div> <div class="helpPaul">help relevant to Paul section</div>
The CSS for .help is display: none; by default so none are shown from the outset.
And here is the jQuery $(".helpTrigger").click(function(){ if (location.hash == '#Ben') {[code].....
In the words of Dr Evil, "throw me a frikkin' bone here..."
ho do itoggle images of a button depending on a check box changep.s. toggle images of a button these are images now depending on check box clicked the image button should show the enabled image.
How can I pick an id element (here #bridge1,#bridge2) and toggle its child (here a p element) without actually using the id element as parent? 'this > p' apparently does not work. $('#bridge1,#bridge2').click(function(){ $('this > p').toggle(); return false; });
I have an online application used for grading students. On one of the pages, I have a table with two rows and each row has 16 cells. The upper row contains the letter grade (A, A-, B+, B, etc) and the lower row has a 16 radio buttons for selecting the appropriate grade. This all writes to a SQL server back-end and has been working fine for several semesters. Some faculty members have complained that it is hard to read and see which have been graded so far and which still need to be graded. It has been suggested that we change the background color of the selected letter grade to a different color. I have had some sucess with this, but haven't figured out how to "toggle" the color on and off based on the state of the radio button. I can get it to change color when selected, but the color persists if another radio button is selected. Does anyone have some sample code for this?
I'm using the following code (simplified version) to call a Json file, parse it and on each iteration, create a div with an ID of "tab". I'm using this with jQuery UI .tab() to create a listing with entries which have three tabs. Anyhow, the principle seems to work except that when I examine what's happening behind the scenes using Firefox console, I see that each href in the html code produced is causing the Json function to re-fire using the href as it's url target.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
i want already select .postlike in $(this) now i want to select the tagh1 who is in .commentboxelements.i want to change the h1's inside text 1 to 2 so i write the code
$(this).closest('.posts').children('.commentboxelements center h1').html('1');
i try this but it's not worked anyway how i can do this.
so i wrote this slider with some help from an admin, everything works as I would like it to but I'm trying to make it a plugin so i need to tighten up a certain part of the code:
(function( $ ){ $.fn.jmSlider = function() { // get total width of all li elements in the slider var wrapWidth = 0;
[code]....
what i would like to do is instead of using "li:first" and "li:last", i would like to use first-child and last-child so the element doesn't need to be a li, in can be anything that is the direct child of the parent container.
I'm extremely new to jquery and trying to write a toggle function without using the built-in functionality. From what I've read, this should be a fairly straightforward exerciseHowever, I'm running an issue. My code doesn't seem to do anything. Not clear to me why because nothing is erroring out? Here's what I've got:
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> // we will add our javascript code here
I have a difficult work around Jquery. I want to remove all li items from the ul except first li and last three li how to remove the li elements from these list.
I have created parent child checkboxes. When one child is selected, then parent of that child, other child of same name and parent of that same name's child will be selected... Now I want if I unchecked any child, then only same name of child and parents should be unchecked or if I unchecked Parent Child, then same name of parent and child will be unchecked.
I have a link and a div on a webpage. With the link I want to toggle the content (HTML) of the div. On toggle, I want to load the content from a PHP-file and I want it to load on the toggle, not when the webpage originally loaded (to reduce loading time on the webpage itself).
The file that is loaded on toggle doesn't have to be PHP, but it would help a lot.
This pops up a new window with every call. In the child window I call a parent function onbeforeunload, appClose() :
function appClose(){
if (window.opener && !window.opener.closed){ window.opener.CloseChild(getQueryString("application")); }}
This is in my frameset tag of the child code :
<frameset ... onbeforeUnload='appClose()'>
The window.opener.CloseChild() function is called perfectly when I have one child window open, but as soon as I create another child window both of the open child windows don't ever call it. They do both go into the onbeforeunload appClose() function, but do not call the window.opener.CloseChild() function inside of this routine.
Anyone have any ideas why when I have two child windows open I can't access the window.opener functions?
I have tried taking each new window out of the array and used the following code in CloseChild() :
i want to make an animation where one value depends on the other.
Let's say i want to animate both the 'top' and 'marginTop' properties, where i want the marginTop property to use the current value of the 'top' property.
$("#ltr").live("mouseover", function() { //swap class names $("div#container").removeClass("rtl").addClass("ltr"); }); I run this function to swap class names when there is a mouseover event on an image with the ID "ltr". How would I run this same function but to occur when, for example, a variable "distance" was equal to 0? Basically, if distance = 0 then swap class names
I want to add a button, beside the "Add" and "Remove" button which pick random of users depending on a given value, lets say that the value is 2, then it would pick 2 users randomly and move them to box 2.
I'm fairly new to jquery and slowly picking it up as I go. Here is a problem I though would be simple-ish but I am stuck. I think I have most of what I need, I just need the correct way of writing 1 part of it.
I have the following Javascript code and I can't seem to get it to work properly...
function DeleteSelectedBookmarks() { bookmarksToBeDeleted = array(); if (document.deletebookmark.elements.length == 1) { if (document.deletebookmark.deletebookmark.checked) array_push(bookmarksToBeDeleted, document.deletebookmark.deletebookmark.value); } else { checkboxes = document.deletebookmark.deletebookmark; for (i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) array_push(bookmarksToBeDeleted, checkboxes[i].value); }} if (count(bookmarksToBeDeleted) == 0) { alert("You haven't selected any bookmarks to delete."); return; } $.get("bookmarks.php", {delete: serialize(bookmarksToBeDeleted)}, function (result, bookmarksToBeDeleted) { if (result == "done") { if (count(bookmarksToBeDeleted) == 1) alert("Bookmark Deleted."); else alert("Bookmarks Deleted."); } RefreshBookmarks(); });}
What it is supposes to do is gather the amount of bookmarks that need to be deleted and then send the command to the server to do so. The server then gives a message back (if it is successfully the result is "done") and depending upon how many bookmarks it deleted it gives a different result, ie. singular vs. plural. How do I do this?
If I have an 'dynamic' Div that sometimes contains the word Red or sometimes contains the word Green, i would like to replace (or something) the ID to something else.If the word inside the div is Green I need to use a green background, but if the word is red in the div, i need to have it in a red background.
I was wondering if there is a way to use Jquery to reduce the amount of images I use on my company website as well as resize them depending on the page they're displayed on. It's just that I feel that's it's very tedious creating 5 or 6 formats for each campaign each with it's own dimensions depending on the page and unfortunately my company doesn't want to implement a Backoffice fed site, which means I have to do it all manually.
How to change style on a series of divs (with similar structure but different content) *only if* all the children are visible (that's using visibility, not display). Sample div: <div class="h"> <p class="a1">text</p> <p class="b2">more text></p> <p class="b3">text text</p> <p class="a4">text...</p> <p class="link_display_none_visibility_visible">div name</p></div> I think it needs to use contents(), but not sure about handling node numbers.
What I'm trying to do is create three rules depending on the path of a page. If the path contains 'best-sellers', I want jQuery to set the class of the page to 'pm-best-sellers'. I can do this, and it works, but when I add the rules for 'express-gifts' and 'eco-friendly' it breaks.