I'm not a programmer, but I think the problem I'm having has something to do with variable scope. Here's what's happening:
I have a function that slides one div up and another one down. There is a button (input.click_target) that the user clicks. The script finds the parent div of the button, which I call curInternal and which needs to be collapsed, and then the parent div of that, which I can curWrapper. It then finds the next wrapper div and the internal div that needs to be expanded.
$('.click_target').click(function (){ //define the objects var curInternal = $(this).parents('div.wrapper'); var curWrapper = $(curInternal).parents('div.expando'); var nextWrapper = $(curWrapper).next('div.wrapper'); var nextInternal = $(nextWrapper).find('div.expando') ; // hide the current div $(curInternal).slideUp(); // show the next one $(nextInternal).slideDown('slow',function(){}); })
This all works fine.
What I want to do is to set a delay on the second step. So I added a setTimeout to the last line:
I think the script somehow loses the meaning of nextInternal, because if I rewrite it to use the object's actual ID, it works fine with the setTimeout.
Can anyone explain to me 1) what's happening, and 2) how to fix this?
I have a bunch of radio buttons, each with an inline event handler ('onclick') that calls a function. This is in the HTML, like so:
<input type="radio" onclick="do_something()">
And in the doc head I have a function that does something with the particular radio button that has been clicked:
function do_something() { $(theRadioButtonThatWasClicked).doSomeStuff... }
How do I pass to the function the information about which radio button was clicked, so I can refer to that radio button (without having to specify it by a unique ID)?
I'm sure this is a pretty easy feat, but since I'm not a programmer I'm having trouble figuring out how to do this:
I have a simple, one-handle jQuery slider, and some text which should display the value of the slider. Let's call the slider #slider1 and the text (in a span) is #text. As the user drags the slider, I want the text to continuously update based on slider position. I want it to work like the Pixel value text in this example: http://developer.yahoo.com/yui/examples/slider/slider-simple.html.
I'm sure there's a simple solution to this but my programming skills are very limited; can someone help me?
I have a calendar in which each day is a separate div, and all these are within a container div #cal. When a user mouses over one of the days, I want to figure out the index number of that day's div within #cal. Simplified example:
I can easily get the index of #nov2 from Firebug if I do this in the console: $('#cal div').index($('#nov2')
But, I can't figure out how to write a function so that I don't need to assign an id to each day div. I'd like to be able to just take "this" from the moused-over div, and pass that to a function that can turn it into the needed index.
I realize this is not jQuery specific, but I figured you guys might have some good advice... I often find myself wanting to assign the same ID to multiple elements in a document -- typically when there are several versions of an element which display at different times. Is there a good reason NOT to do this? If so, what's a better practice? thanks, Kim
Just wanted to send a little luv note to the jQuery team. I'm a UI designer and NOT a programmer, but learning jQuery has allowed me to make my software wireframes/prototypes way more functional. Yesterday a client said to me, "I'm amazed at how fast you guys turn around these wireframes." Well, it's mostly due to jQuery. So, a big thank you to the creators, shepherds, and evangelists, and also to the forum experts who have been remarkably responsive and helpful. Cheers! -Kim
I have a bunch of Divs with class ".popup". Each div is different in what it contains; some are simple, some are pretty complex, containing tables, other divs, etc.. If I have a link, for example,"Cancel", within that Div, and the only thing that I know about Cancel is that 1) it has a parent div.popup somewhere up the tree (no idea how many levels), and 2) if I go backwards up the tree from Cancel, the first div.popup I encounter will be the right one, how can I go about finding the right parent div.popup? I'd like to just attach a handler that starts with "this" (meaning the Cancel link) and finds the correct div.popup up the tree. Hope this is question is clear. Thanks! -Kim
Hi all, Is there a simple way to capture a click event in a window/document and then determine whether the click was inside an element #foo, or outside of that element? Thanks! -Kim