Call an external js file and use its internal method to call an external js File

Source: Internet
Author: User
Tags getscript

Call an external js file and use its internal method to call an external js File

I haven't learned jQuery for a long time, so I forget it. I learned a small function today. Using jQuery's $. getScript () method, I read external js files, read them, and execute a method in the js file.

First, create this js file, such as I. js:

 

The Controller of ASP. net mvc is omitted here.

View implementation:

 
Js source code:

$ (Document ). ready (function () {$ ("# Text1 "). click (function () {var v = $ (this ). attr ("value"); $. getScript ('/Scripts/I. js', function () {me ("Hi," + v) ;}); View Code


#16 lines of code are Call external js files. In code #17, the Red Arrow refers to the internal method of js.

Demo:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.