[jQuery] Re: How to make this work for multiple elements with same class
It's a mess. It's best to return false from the function or use e.preventDefault(): $(document).ready(function() { $('.update-link').click(function(e) { $(this).parent().hide() .next().next().fadeIn(500); e.preventDefault(); //same effect as 'return false' }); }); cheers, - ricardo On Jan 13, 7:51 pm, "Charlie Griefer" wrote: > what about a return false; in the js method itself? > $(this).parent().next().next().fadeIn(500); > return false; > > hopefully somebody can elaborate, but i'd heard that using the javascript > "pseudo-protocol" isn't really... "proper"? > > > > On Tue, Jan 13, 2009 at 1:35 PM, Miloš Rašić wrote: > > Instead of href="##", put href="javascript: return false". It will work, > > but be warned that FF will generate a warning because return is not inside a > > function. > > > On Tue, Jan 13, 2009 at 10:06 PM, Rick Faircloth > > wrote: > > >> Thanks, Josh... > > >> You were almost perfect. I just needed to add one more .next to the > >> second line: > > >> $(this).parent().next().next().fadeIn(500); > > >> then it worked. > > >> Another question however, is how to keep the page from going back to the > >> top > >> every time the Update link is clicked. I've got two ## as the href > >> because of > >> ColdFusion need to have two. Is that the problem, or is there another > >> solution? > > >> Update > > >> That's the current code. Suggestions? > > >> Thanks, > > -- > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success.
[jQuery] Re: How to make this work for multiple elements with same class
Thanks, Charlie! Perfecto! Rick From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Charlie Griefer Sent: Tuesday, January 13, 2009 4:52 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: How to make this work for multiple elements with same class what about a return false; in the js method itself? $(this).parent().next().next().fadeIn(500); return false; hopefully somebody can elaborate, but i'd heard that using the javascript "pseudo-protocol" isn't really... "proper"? On Tue, Jan 13, 2009 at 1:35 PM, Miloš Rašić wrote: Instead of href="##", put href="javascript: return false". It will work, but be warned that FF will generate a warning because return is not inside a function. On Tue, Jan 13, 2009 at 10:06 PM, Rick Faircloth wrote: Thanks, Josh... You were almost perfect. I just needed to add one more .next to the second line: $(this).parent().next().next().fadeIn(500); then it worked. Another question however, is how to keep the page from going back to the top every time the Update link is clicked. I've got two ## as the href because of ColdFusion need to have two. Is that the problem, or is there another solution? Update That's the current code. Suggestions? Thanks, -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to make this work for multiple elements with same class
Thanks for the reply, Milos… Charlie Griefer suggested using “return false” also, but suggested putting it in the js method, itself. Works perfectly! Thanks for the suggestion. It’s good to know I’ve got two ways to approach this in case one doesn’t work. Rick From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Miloš Rašic Sent: Tuesday, January 13, 2009 4:35 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: How to make this work for multiple elements with same class Instead of href="##", put href="javascript: return false". It will work, but be warned that FF will generate a warning because return is not inside a function. On Tue, Jan 13, 2009 at 10:06 PM, Rick Faircloth wrote: Thanks, Josh... You were almost perfect. I just needed to add one more .next to the second line: $(this).parent().next().next().fadeIn(500); then it worked. Another question however, is how to keep the page from going back to the top every time the Update link is clicked. I've got two ## as the href because of ColdFusion need to have two. Is that the problem, or is there another solution? Update That's the current code. Suggestions? Thanks,
[jQuery] Re: How to make this work for multiple elements with same class
what about a return false; in the js method itself? $(this).parent().next().next().fadeIn(500); return false; hopefully somebody can elaborate, but i'd heard that using the javascript "pseudo-protocol" isn't really... "proper"? On Tue, Jan 13, 2009 at 1:35 PM, Miloš Rašić wrote: > Instead of href="##", put href="javascript: return false". It will work, > but be warned that FF will generate a warning because return is not inside a > function. > > > On Tue, Jan 13, 2009 at 10:06 PM, Rick Faircloth > wrote: > >> >> Thanks, Josh... >> >> You were almost perfect. I just needed to add one more .next to the >> second line: >> >> $(this).parent().next().next().fadeIn(500); >> >> then it worked. >> >> Another question however, is how to keep the page from going back to the >> top >> every time the Update link is clicked. I've got two ## as the href >> because of >> ColdFusion need to have two. Is that the problem, or is there another >> solution? >> >> Update >> >> That's the current code. Suggestions? >> >> Thanks, >> >> -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to make this work for multiple elements with same class
A sneaky way to do it would be to remove the href attribute altogether, and create a css class that makes the link appear to be hyperlinked: a.fake-link { text-decoration: underline; cursor: pointer; color: [your link color here] } Then add that class to your "non-href" links as desired. -- Josh -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Rick Faircloth Sent: Tuesday, January 13, 2009 1:07 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: How to make this work for multiple elements with same class Thanks, Josh... You were almost perfect. I just needed to add one more .next to the second line: $(this).parent().next().next().fadeIn(500); then it worked. Another question however, is how to keep the page from going back to the top every time the Update link is clicked. I've got two ## as the href because of ColdFusion need to have two. Is that the problem, or is there another solution? Update That's the current code. Suggestions? Thanks, Rick > -Original Message- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Josh Nathanson > Sent: Tuesday, January 13, 2009 3:36 PM > To: jquery-en@googlegroups.com > Subject: [jQuery] Re: How to make this work for multiple elements with same class > > > Rick - I think you want $(this).parent().hide() rather than prev, and > $(this).parent().next() rather than next(). Prev and next look at the > sibling level. > > -- Josh > > > -Original Message- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > Behalf Of Rick Faircloth > Sent: Tuesday, January 13, 2009 12:17 PM > To: jquery-en@googlegroups.com > Subject: [jQuery] Re: How to make this work for multiple elements with same > class > > > Ok...made that change, but no difference in the execution. > > Here's the relevant js and html/cf: > > $(document).ready(function() { > > $('.update-link').click(function() { > > $(this).prev('.options').hide(); > $(this).next('.update-div').fadeIn(500); > > }); > }); > > > > [ Preview ] > [ Update ] > [ Delete ] > > > > > > > Edit Link: > value="#tour_url#"> > > > > > > > > > > > -----Original Message----- > > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > Behalf Of MorningZ > > Sent: Tuesday, January 13, 2009 3:05 PM > > To: jQuery (English) > > Subject: [jQuery] Re: How to make this work for multiple elements with > same class > > > > > > to start: you have > > > > $('this') > > > > it should be without the ticks > > > > $(this) > > > > On Jan 13, 2:50 pm, "Rick Faircloth" wrote: > > > Here's the code that I'm trying to make function > > > for multiple links on a page with the class of "update-link" > > > > > > How would I change this to make it work for the specific > > > .update-link element that I click? > > > > > > $(document).ready(function() { > > > > > > $('.update-link').click(function() { > > > > > > $('this').prev('.options').hide(); > > > > $('this').next('.update-div').fadeIn(500); > > > > > > }); > > > }); > > > > > > Thanks, > > > > > > Rick
[jQuery] Re: How to make this work for multiple elements with same class
Instead of href="##", put href="javascript: return false". It will work, but be warned that FF will generate a warning because return is not inside a function. On Tue, Jan 13, 2009 at 10:06 PM, Rick Faircloth wrote: > > Thanks, Josh... > > You were almost perfect. I just needed to add one more .next to the second > line: > > $(this).parent().next().next().fadeIn(500); > > then it worked. > > Another question however, is how to keep the page from going back to the > top > every time the Update link is clicked. I've got two ## as the href because > of > ColdFusion need to have two. Is that the problem, or is there another > solution? > > Update > > That's the current code. Suggestions? > > Thanks, > >
[jQuery] Re: How to make this work for multiple elements with same class
Thanks, Josh... You were almost perfect. I just needed to add one more .next to the second line: $(this).parent().next().next().fadeIn(500); then it worked. Another question however, is how to keep the page from going back to the top every time the Update link is clicked. I've got two ## as the href because of ColdFusion need to have two. Is that the problem, or is there another solution? Update That's the current code. Suggestions? Thanks, Rick > -Original Message- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > Behalf Of Josh Nathanson > Sent: Tuesday, January 13, 2009 3:36 PM > To: jquery-en@googlegroups.com > Subject: [jQuery] Re: How to make this work for multiple elements with same > class > > > Rick - I think you want $(this).parent().hide() rather than prev, and > $(this).parent().next() rather than next(). Prev and next look at the > sibling level. > > -- Josh > > > -Original Message- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > Behalf Of Rick Faircloth > Sent: Tuesday, January 13, 2009 12:17 PM > To: jquery-en@googlegroups.com > Subject: [jQuery] Re: How to make this work for multiple elements with same > class > > > Ok...made that change, but no difference in the execution. > > Here's the relevant js and html/cf: > > $(document).ready(function() { > > $('.update-link').click(function() { > > $(this).prev('.options').hide(); > $(this).next('.update-div').fadeIn(500); > > }); > }); > > > > [ Preview ] > [ Update ] > [ Delete ] > > > > > > > Edit Link: > value="#tour_url#"> > > > > > > > > > > > -Original Message----- > > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > Behalf Of MorningZ > > Sent: Tuesday, January 13, 2009 3:05 PM > > To: jQuery (English) > > Subject: [jQuery] Re: How to make this work for multiple elements with > same class > > > > > > to start: you have > > > > $('this') > > > > it should be without the ticks > > > > $(this) > > > > On Jan 13, 2:50 pm, "Rick Faircloth" wrote: > > > Here's the code that I'm trying to make function > > > for multiple links on a page with the class of "update-link" > > > > > > How would I change this to make it work for the specific > > > .update-link element that I click? > > > > > > $(document).ready(function() { > > > > > > $('.update-link').click(function() { > > > > > > $('this').prev('.options').hide(); > > > > $('this').next('.update-div').fadeIn(500); > > > > > > }); > > > }); > > > > > > Thanks, > > > > > > Rick
[jQuery] Re: How to make this work for multiple elements with same class
Rick - I think you want $(this).parent().hide() rather than prev, and $(this).parent().next() rather than next(). Prev and next look at the sibling level. -- Josh -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Rick Faircloth Sent: Tuesday, January 13, 2009 12:17 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: How to make this work for multiple elements with same class Ok...made that change, but no difference in the execution. Here's the relevant js and html/cf: $(document).ready(function() { $('.update-link').click(function() { $(this).prev('.options').hide(); $(this).next('.update-div').fadeIn(500); }); }); [ Preview ] [ Update ] [ Delete ] Edit Link: > -Original Message- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of MorningZ > Sent: Tuesday, January 13, 2009 3:05 PM > To: jQuery (English) > Subject: [jQuery] Re: How to make this work for multiple elements with same class > > > to start: you have > > $('this') > > it should be without the ticks > > $(this) > > On Jan 13, 2:50 pm, "Rick Faircloth" wrote: > > Here's the code that I'm trying to make function > > for multiple links on a page with the class of "update-link" > > > > How would I change this to make it work for the specific > > .update-link element that I click? > > > > $(document).ready(function() { > > > > $('.update-link').click(function() { > > > > $('this').prev('.options').hide(); > > $('this').next('.update-div').fadeIn(500); > > > > }); > > }); > > > > Thanks, > > > > Rick
[jQuery] Re: How to make this work for multiple elements with same class
Ok...made that change, but no difference in the execution. Here's the relevant js and html/cf: $(document).ready(function() { $('.update-link').click(function() { $(this).prev('.options').hide(); $(this).next('.update-div').fadeIn(500); }); }); [ Preview ] [ Update ] [ Delete ] Edit Link: > -Original Message- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > Behalf Of MorningZ > Sent: Tuesday, January 13, 2009 3:05 PM > To: jQuery (English) > Subject: [jQuery] Re: How to make this work for multiple elements with same > class > > > to start: you have > > $('this') > > it should be without the ticks > > $(this) > > On Jan 13, 2:50 pm, "Rick Faircloth" wrote: > > Here's the code that I'm trying to make function > > for multiple links on a page with the class of "update-link" > > > > How would I change this to make it work for the specific > > .update-link element that I click? > > > > $(document).ready(function() { > > > > $('.update-link').click(function() { > > > > $('this').prev('.options').hide(); > > $('this').next('.update-div').fadeIn(500); > > > > }); > > }); > > > > Thanks, > > > > Rick
[jQuery] Re: How to make this work for multiple elements with same class
to start: you have $('this') it should be without the ticks $(this) On Jan 13, 2:50 pm, "Rick Faircloth" wrote: > Here's the code that I'm trying to make function > for multiple links on a page with the class of "update-link" > > How would I change this to make it work for the specific > .update-link element that I click? > > $(document).ready(function() { > > $('.update-link').click(function() { > > $('this').prev('.options').hide(); > $('this').next('.update-div').fadeIn(500); > > }); > }); > > Thanks, > > Rick