My HTML is like this:
<div class="feature">
<h2>Heading Goes Here</h2>
<img src="photo.jpg" />
[Code]....
What I want to happen is for the element inside the .feature class to appear when the <h2> of that <div> is clicked I tried using next() and a few other methods but it doesn't work as neatly as I want it to - how can I tell jQuery to just return the element within that div (and not all elements which are inside a .feature class)?
please see the code below.at the moment, when you click img, click eventtriggeredbecause parent element has click event.I want click event not to be triggered when you click img.How would I do that?
i have a menu generated by a list with nested lists. i want the parent link to stay highlighted when the mouse hovers over the sub menus. because those sub menus are also generated by jquery (qtip), CSS alone won't do it (triedul.topnav li:hover a {background-color: #F00;}).is there a way to do this using jquery?
The bit of code in bold in the code below is giving me this error in IE: Error: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; Tablet PC 2.0; InfoPath.2; OfficeLiveConnector.1.4; .NET CLR 3.0.30729; OfficeLivePatch.1.3; MSN OptimizedIE8;ENGB)Timestamp: Tue, 16 Mar 2010 15:07:11 UTC Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
I have a javascript here for adding my div element to my registration form,Adding the div element is easy, but it shows on the bottom of my form. I cant make it as the first child element of my form...This is my code
var _form = document.getElementById('registration_form'); var errorDiv = document.createElement('div'); errorDiv.setAttribute('class', 'confBox');
I've got a reference to a TableCell and I'd like to use jQuery to get the first instance of an <IMG> tag within that TableCell, but can't get the syntax right, I understand how it would work if I were to reference the TableCell by and ID or class, but not when I have a direct reference to the cell, I've got:
What the jQuery syntax should be to get the first img tag within "tdRef"?
I'm using the following code that adds to <a> tags to each <td> inside a table. $(document).ready(function() { $('.calendar td:not(.notinmonth.)').each(function() { $(this).append('<a href="#" class="available am">AM: Available</a>').append('<a href="#" class="available pm">PM: Available</a>'); }); $('.calendar td:not(.notinmonth.)').each(function() { $(this).has('.event').remove('.am'); }); });
The second half of the code looks to see if any of the cells contain an element with class 'event'. If one exists, then the '.am' anchor should be removed. However this does not appear to be happening. After carrying out a few tests with the 'alert' function, it looks as though the script thinks that every cell contains a '.event' element, but I have no idea why! Not only that, it doesn't remove the '.am' link from any of them.
Here is the markup for the table (the cell with 'Day 9' in it is the only one that should match having an '.event' element: <table class="calendar"><thead> <tr><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th> <th class="weekend">Sat</th><th class="weekend">Sun</th></tr> </thead><tbody> <tr><td class="notinmonth"></td><td class="notinmonth"> .....
I've 2 field sets and a div inside each fieldset with some contents. When the legend of the current fieldset is clicked, I will toggle the div contents. I'm trying to write a generic function which can be used by everyone. Here is my design:
I have the usual unordered list for a navigation menu with submenus...
html:
<ul> <li><a href="#">Link 1</a></li> <li>
[code].....
All of the links inside of the parent <li> have a border radius. But if the parent <li> has a child <ul>, I don't want the link to have a radius.I'm currently using this jQuery:
Basically, I'm looking for a way to find a list element that has a ul child, and then hide or show that ul. What I have here doesn't seem to be working.
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 was wondering if there is a "selector construct" that matches an element having more than one child. So I'm looking for a solution that doesn't need an if statement such as;
if($('ul').children().size()>1) { //do this }
[Code]....
But I'm looking for a selector that already looks for these conditions. Kind of like how :has() works but then a check for more than one child.
I'm customizing the cycle plugin a bit from [URL] , which slides through a number of items.The issue I have is selecting a child object, to get its 'alt' attribute, and display it as a description. Using the default example:
function onBefore() { $('#output').html("Scrolling image:<br>" + this.alt ); }
...works great when each item is an image. But I need to link each element, so my markup looks like this:
i am curious if there is a simple solution to this very common problemim sure lots get.i have a div with some children items in it and when i fade one ofthem out the div jumps down to the appropriate height. i would like toknow is there a simple way to animate the div to shrink nicely insteadof just jumping to its new size?
I'm trying to use a :not statement, so if you click anywhere else on the page BUT the element in the :not a div will disappear. When i use the same statement without the not, it works fine (click that one element and the div in the function hides).I'm assuming that the :not statement isn't working because the element is a child of its parent, so when you click it, essentially you are still clicking the parent which isn't included in the :not.
I'm using simple jQuery dropdown menu Code: <script type='text/javascript'> jQuery(document).ready(function() { jQuery("#dropmenu ul").css({display: "none"}); jQuery("#dropmenu li").hover(function(){ jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).show(268); },function(){ jQuery(this).find('ul:first').css({visibility: "hidden"}); }); }); </script> What I need is: when someone clicks on submenu that element would be stay displayed under parent element.
In jQuery, how to select a parent element to a child if I attached a click event on the parent but also want a click event on a child within.
Let's say I have a the following code :
HTML Code:
There may be several of those classes in the page. I then use jQuery to replace the inner HTML to the clickclass div when clicked on with some other code and a input button (with an ID of, let's say 'save_button').
This works fine for that part:
HTML Code:
I then want to have the button clickable so that I can replace again the HTML in the div (like a save button). But if I try a separate event listener on the input button, it also fires the parent event. Even if I return false on the child event or use event.stopImmediatePropagation() in the .click child function.
I've managed to almost get it with the following code :
HTML Code:
If the event is triggerd form 'clickclass', then replace with HTML + input button
The problem is that whenever I try using .parent() with jQuery, it always tells me that parent() is not a function. I've tried various other ways of getting the parent object (the clickclass div) but can't get it to work.
I found this plugin is helpful,but has issue with ie 7,works in firefox What I want is that prepend and slide down effect,but there must be a table wrap the text. Here is my code
I created a dropdown menu using jquery. So when I hover over a button it slides down the menu. Now if I move the mouse out of the menu and bring it back in before it slides up(menu has a lot of items so there is enough time to bring the mouse back in on the menu)over the dropdown menu it starts a chain of slideDown() and slideUp() functions and it does not stop till I move the mouse of the menu or back on the button. Below is my jquery code:
I`m trying to make selecting an select list option (as it become when we click on it)by clicking on a special pseudo element.I`m trying to do it in this way:
How do I get the contents of an element in the opener and show them in the child?
What I'm trying to do is something like this:
In the opener: <h1 id="pgtitle">Office XP</h1>
In the child: function gt_pageCont () { var pagetitle = window.opener.document.getElementById("pgtitle"); var pagetext = "<h1>""+title+""</h1><p>Here are some more info about "" +title+ "".</p>"; document.write(pagetext); }
and: <body onload="gt_pageCont();">
I know that something is missing in the function, because I've tested it and the child displays [Object] instead of "Office XP".
I have a function which looks like function mainLeftElements(){ var containerDiv = document.getElementById('mainLeft'); var elems = containerDiv.childNodes; alert(elems.length); }
Which for a div declared like so: <div id = 'mainLeft'></div> Alerts me it has a length of 1, trying to work out what the element is (thinking it might be a blank text element or something, maybe the id attribute also??) by using elems[0].tagName and elems[0].id I get confused as they both return 'undefined', so what is it?
alerts me it has a length of 1, trying to work out what the element is (thinking it might be a blank text element or something, maybe the id attribute also??) by using
and
i get confused as they both return 'undefined', so what is it?