How do I return false for click handler for this button?
I have a button that should open up a popup for a Facebook invite window but the button reloads the page. How to I handle this click so that it returns false? I.e. What is the syntactically开发者_开发问答 correct way of doing this?
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
$(function(){
$("a#invite_fb_friends").click(function() {
FB.init({
appId:'257395654482349',
cookie:false,
status:true
});
FB.ui({
method: 'apprequests',
message: 'Test message. '
});
});
});
</script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
$(function(){
$("a#invite_fb_friends").click(function() {
FB.init({
appId:'257395654482349',
cookie:false,
status:true
});
FB.ui({
method: 'apprequests',
message: 'Test message. '});
return false;
});
});
</script>
is this what you are looking for?
Just add return false;
to the end of the function?
$(function(){
$("a#invite_fb_friends").click(function() {
FB.init({
appId:'257395654482349',
cookie:false,
status:true
});
FB.ui({
method: 'apprequests',
message: 'Test message. '
});
return false; //Disable default behavior.
});
});
精彩评论