I just started using jquery a few days ago and am already addicted.Now I am trying to figure out one thing which I can't seem to get answered by Google:I am building a dynamic website where at one place there will be an unclear number of div-elements. So there can be none, just one or several.The plan is to show them by a click on a button via slideDown(). So I wrapped them with another div.wrapper via wrapAll(). This works nicely for any number.Now the thing is: if my .wrapper has no specified height, the slideDown jumps - which doesn't look very nice.So I gave it a height:$('.wrapper').css({'height': $('div').outerHeight()});Presto, the animation works smoothly. But this works only if there's just one div.
I have a div that is absolutely positioned and stretch on all sides using top: 10px; left: 10px; bottom: 10px; right: 10px; When I try to get the height of the div, using $('#id').height(); I get 0 (zero). Is there a problem calculating the height of elements like this one, or am I missing something?
I am using jquery with the cookie plugin and I have multiple image buttons that can hide/show multiple elements. My question is how can I add a cookie to this code to remember whether each separate element is opened or closed?
The code, $(document).ready(function() { // choose text for the show/hide link - can contain HTML (e.g. an image) var showText='<div class="expanddown"></div>'; var hideText='<div class="expandup"></div>'; // initialise the visibility check var is_visible = false; // append show/hide links to the element directly preceding the element with a class of "toggle" $('.toggle').prev().append('<a href="#" class="togglelink">'+hideText+'</a>'); // capture clicks on the toggle links $('a.togglelink').click(function() { // switch visibility is_visible = !is_visible; // change the link depending on whether the element is shown or hidden $(this).html( (!is_visible) ? hideText : showText); // toggle the display - uncomment the next line for a basic "accordion" style //$('.toggle').hide();$('a.toggleLink').html(showText); $(this).parent().next('.toggle').slideToggle('fast'); // return false so any link destination is not followed return false; }); }); HTML, <a class="togglelink" href="#"></a> <div class="toggle"> Content </div>
I am trying to get the height of a div that is inside 7 other divs. I noticed the height() method works with the first and second div, but it does not work after that.
Example : <div id="first"> <--------------------------- $("first").height(); works ![code]....
how to get the height of a div that is inside multiple other divs ?
I have a hidden popup that I populate with content and it dynamically expands to the size of the content. I then show the popup. When a user clicks on another link, it populates the popup with longer or shorter content. When the content is SHORTER, it seems to show the background image that I'm using expanding to the height of the previous size of the popup. I've tried setting the height manually with JS, no luck. This only happens on IE6.
The cover group contains left & right bar images that repeat vertically as the page expands. The top is just a simple blue background (also content bg color)
Obviously content is the content of the page and both covergroup and content are within the subbody.
Is for the <subbody> tag to be the size of <content> + 5px on top (size of the <covertop>), and the left and right cover divs to expand to the size of subbody.
I guess since I'm using a footer (with image and text) letting the page expand as it wants is out, and I need javascript to make it work.
I want to do this with js and not with any html/css tables, image fills or whatever other trick, but I don't know how...
Say I have multiple DIV containers below each other, which contain multiple DIV boxes floating next to each other. None of the DIV elements have a fixed height:
<div id="container1"> <div id="box1">some text</div> <div id="box2">some double more text</div> <div id="box3">some other text</div>
[Code]....
I want for each container (separately) to have the contained box divs to fit the biggest one in height.
For example, in container1, if box2 contains more text than the others, I want box1 and box3 height to fit box2. And in container2, if box4 has more text than the others, I want box5 and box6 height to fit box4, etc.
In my dreamworld, the solution would be flexible and fully automated, which means, it would look for all container divs of class x or Id x and apply the same rule to all child divs.
I have heard of jquery "equalheights" plugin but I don't think it can do that ? or then I misunderstood something. Could I be using some "get element by class" function and then apply a style.height to the divs?
I'm working on my personal website [URL] and I'm trying to use Javascript to edit some of the height and size attributes of elements on the page, based on the user's window size. I've got the code that gets the window size working, and calculates what I want to set as the "boxSize" but the part that goes into the external CSS to change the values is not working. "boxSize" is a variable that holds just a number. I'm not sure if it's really stored as a number or a string, but I don't think that's supposed to affect anything.
I'm just putting in the relevant part of the code right where it's failing. I figured out (using alert() statements) that the script is definitely working right up until before the two lines given, and failing to get through them.
I've selected multiple tables and tried to use each for applying cornering to each table. Inside the callback function, I try to find the first/last table cells to apply cornering for each corner. However, when there are multiple tables it looks at _all_ the tr elements for the first/last rows. See example code:
// Add cornering to tables $('table.corner-me').addClass('ui-corner-all').each(function(){ var $table = $(this); $table.find('tr:first :first-child').addClass('ui-corner-tl');
Can someone explain to me the best way to loop through the geocode and marker (google maps) part of this code for all of the elements with the "address" class using jQuery (or javascript if need be). I tried wrapping the contents of the codeAddress function in $(".address").each(function () {... and replacing the getElementById with a jquery selector, but I still seem to be lost.
But when there are multiple classes, it only deletes the first element in its query. As a successful test, I appended some CSS to ensure the query selected all classes and added a border to each element. So why does remove() not work? Is it a bug or is my query missing something?
I am putting together a validation function and am having trouble with targeting multiple elements.[code]an onclick event fires my validation function. If any of the fields are empty, the appropriate error message should display.This sort of works. If all of the fields are empty, only the error message of the first element is displayed, not all 3.
Im working on a ajax app and not sure what is the best way to bind events to elements (performance wise).I have a number of elements with 'click', 'focus', 'keydown' events which can be assigned though the delegate to the parent, like so:$('#parent').delegate('#child', 'click', func.....)but is it better to add a delegate to the 'document' for multiple events and use IF statement to filter for elements which should fire an event, like so:[code]Each element can be replaced with an updated version retrieved from the server.
I am learning jQuery now and have a big interest in this javascript framework. I am trying to bind an event to more than one element. I won't meet any problem if using selector. But now, I've created a function which I will pass the element. And I need within this function, to bind the code. This is my current code :
function updateDay(dayObj, monthObj, yearObj){ //I want to bind both monthObj and yearObj. yearObj.change(function(){ //do something }); monthObj.change(function(){yearObj.change()}); } $(document).ready(function(){ updateDay( $("#day"), $("#month"), $("#year")); });
As you can see, I must bind twice, once for yearObj, the other for monthObj. Is there anyway to bind the change() event only once? If there are some logic mistake in using function or such as feel free to point out, since I still haven't read all the documentation yet.
Im trying to get 2 elements to execute some effect individually at the same time on a hover.Ive looked at .animate but if I understand it correctly I can do multiple effects but still limited to that single element.[code]So basically Im just trying to get 1st & 2nd on hovers to happen at the same time and 1st and 2nd off hovers to happen at the same time.
I'm wondering how to get access to each element I selected e.g. by the :has()-Selector. To explain a bit more: I want to select several elements and add to each of them attributes, but a different one to each element. So how can I run through the elements and modify each one?
Selecting elements using multiple parameters like here: $('descendant', 'ancestor').text(); seems to be way more popular than css-like syntax: $('ancestor descendant').text(); Do those two differ in performance, or is it just about being intuitive to particular people?
I am creating an FAQ type page with rows of questions that will drop down the respective answer when clicked. I have it mostly working, except I can't find a way to close all answers before opening the next one. I have tried everything I can think of (or search), but to no avail. I am using the following code, where QQQ1/2 are the questions, and AAA1/2 are the answer divs:
//Question/Answer $(".QQQ1,.QQQ2").click(function () { // check the visibility of the next element in the DOM if ($(this).next().is(":hidden")) {
I'm writing a bookmarklet which allows you to select various elementsfrom a page and save them to your own personal blog (a bit likeffffound or the Wordpress PressIt feature)The user will select 3 parts from the page they want to save:1) Title (easy, just detect a click on an html element and make sureit's a span/p/h1/h2/h3 etc)2) Image (i've figured this out too)3) Body textI'm stuck with grabbing the body text - I think it should be selectedmanually, as it could consist of multiple p's and div's, or even tablerows, depending on how badly the source page has been coded.When the use has selected the text, it should be highlighted somehowen/browse_thread/thread/6dbbfd9cafd98cf6,I know that getSelection won't work, but I'm not sure what to doexactly.
The default behaviour for a class selector is: "An element can have multiple classes; only one of them must match." Is there a class selector where you can use multiple classes and all of them have to match?
just a very basic question. Have a div (id - photos) with multiple images. 1) Does this select them all? $('#photos img') 2)If so, how can i capture this information? Like so -> var bunchOfStuff = ($('#photos img')); and 3) if so, why can't i do something like alert(bunchOfStuff.length)into code tags...
I've got a list of links and divs. When I click on a link I want to keep showing all the divs which have a class that matches the clicked link id and hide all the divs which don't. At the same time I want to add another class (.item) to the matching divs and remove it from any div which is hidden.
When I run the code below, clicking any of the links hides all the divs apart from the one which doesn't have a matching colour class.
$('a.filterclick').click(function(){ var id = $(this).attr('id'); if($('.filterclass').hasClass(id)) {$('.filterclass').removeClass('filteredout').addClass('item'); }else