Home › Forums › JavaScript › jQuery "return false"
- This topic is empty.
-
AuthorPosts
-
March 17, 2009 at 6:48 am #24360Historical Forums UserParticipant
I’m trying Chris’ tutorial #20. It is below all the widgets http://www.aaronheine.com
I had to add "return false" to keep the links from making the page jump to the top of the browser. But the first link is not working with "return false" Am I entering it correctly? I tried a couple different ways.
Code:jQuery(document).ready(function() {
jQuery(“li.action-one”).click(function(){
jQuery(“#page-wrap2”).animate({
width: “300px” return false;});
});
jQuery(“li.action-two”).click(function(){
jQuery(“p”).toggle(); return false;});
jQuery(“li.action-three”).click(function(){
jQuery(“#header2”).slideUp(); return false;});
});Thanks
March 17, 2009 at 10:33 am #55067Rob MacKayParticipantyou could try…
Code:jQuery(document).ready(function() {
jQuery(“li.action-one”).click(function(){
jQuery(“#page-wrap2”).animate({
width: “300px”
});
return false;
});jQuery(“li.action-two”).click(function(){
jQuery(“p”).toggle();});
return false;
jQuery(“li.action-three”).click(function(){
jQuery(“#header2”).slideUp();});
return false;
});
March 18, 2009 at 3:25 am #55098Historical Forums UserParticipantNow it is not working at all. :( Seems like there are a lot of quirks to working with jquery/PHP. This is my entire header if you want to give it another try.
Thanks
Code:
>
» Blog Archive
jQuery(document).ready(function() { jQuery("li.action-one").click(function(){ jQuery("#page-wrap2").animate({ width: "300px" }); return false; }); jQuery("li.action-two").click(function(){ jQuery("p").toggle();
}); return false; jQuery("li.action-three").click(function(){ jQuery("#header2").slideUp();
}); return false; });
jQuery(function(){
jQuery.getJSON('http://twitter.com/status/user_timeline/aaronheine.json?count=3&callback=?', function(data){ jQuery.each(data, function(index, item){ jQuery('.twitter .inside').append('
' + item.text + '
'); }); });
jQuery.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=80049922@N00&lang=en-us&format=json&jsoncallback=?", function(data){ jQuery.each(data.items, function(index, item){ jQuery("").attr("src", item.media.m).addClass("thumb").appendTo(".flickr .inside").wrap("").wrap("
"); }); });
});
March 18, 2009 at 5:41 am #55104Rob MacKayParticipantyea it was a random stab in the dark as to say lol – I shall have another look, cant promise anythin though :)
March 18, 2009 at 6:17 am #55108Rob MacKayParticipantOk this works for me…
Code:jQuery(document).ready(function() {jQuery(“li.action-one”).click(function(){
jQuery(“#page-wrap2”).animate({
width: “300px”
});
return false;
});jQuery(“li.action-two”).click(function(){
jQuery(“p”).toggle();
return false;
});jQuery(“li.action-three”).click(function(){
jQuery(“#header2”).slideUp();
});
return false;
});Just to point out you had an extra ";" after your width: "300px" – so I took that out and it removed an error :)
April 11, 2009 at 6:22 am #56127jackfranklinMemberAn easier way is to pass the event throught the function and use the preventDefault function in jQuery:
Code:$(“li”).click(function(event) {
event.preventDefault(); //link wont go to destination now
..do the rest of your stuff…
}); -
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.