I have noticed one of my friend using this.
<a href="#" onclick="return Buy();">» <b class="font_bigger"><span id="buy_title">Buy</span> for <span class="points_in" id="buy_value">$1,691</span></b></a>
And i have feel no changed if i use this.
<a href="#" onclick="Buy();">» <b class="font_bigger"><span id="buy_title">Buy</span> for <span class="points_in" id="buy_value">$1,691</span></b></a>
So can any one explain what is the difference in both?
Just curious to know why he always use return.
Thanks
In the first example a value will be returned from the onclick
handler. This could be used to return false
which would prevent the default behavior.
<a href="#" onclick="return Buy();">» <b class="font_bigger"><span id="buy_title">Buy</span> for <span class="points_in" id="buy_value">$1,691</span></b></a>
In the second example, the event handler will simply run, the event will propagate and the default behavior will execute regardless of any value returned by the event handler.
<a href="#" onclick="Buy();">» <b class="font_bigger"><span id="buy_title">Buy</span> for <span class="points_in" id="buy_value">$1,691</span></b></a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With