Home  >  Article  >  Web Front-end  >  The jquery statement written in the page is executed normally, but it cannot be executed when placed in the JS file_html/css_WEB-ITnose

The jquery statement written in the page is executed normally, but it cannot be executed when placed in the JS file_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:52:151434browse

RT,
The page is

<script>$("form#login").submit(function(){		***********});</script>

. Remove the script tag and put it into the JS file intact, then import it.


cannot be called.

Reply to discussion (solution)

$(function(){
$("form#login").submit(function(){
                                                                                 ***
});
})

$(function(){$("form#login").submit(function(){        Your code here!});});

If it cannot be executed, please show the error reported by the browser first. I think it may be jquery and you. The js files are introduced in the wrong order

Brother, how can you run it if you don’t plan on it?
$(document).ready(function(){
//Put the function you want to run here
});

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn