JavaScript 'onclick' event 'return' keyword functionality

前端 未结 3 514
情深已故
情深已故 2020-12-04 11:18

I am really new to javascript, and stumbled upon the return keyword. Basically, what is the difference in terms of these 2 statements?



        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 12:10

    adding return to a function(), it disables the default behaviour of the browser, it disables the job of submit. Means it will keep you on the same page if the function returns false and you can fill up the value into the field again.

    If you do not use return with the function() then submit function will perform its job, it will redirect to the next specified page, without caring about the returned result whether it was true or false.

提交回复
热议问题