在layui.use 中自定義 function 的正確方法
更新時間:2019年09月16日 08:40:02 作者:肖朋偉
今天小編就為大家分享一篇在layui.use 中自定義 function 的正確方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
適用于:
obj.click()
行內(nèi) onclick
javascript:函數(shù)名()
示例代碼:
<html> <head> <link rel="stylesheet" href="layui/css/layui.css" rel="external nofollow" media="all"> </head> <body> <a class="layui-btn" id="test" href="javascript:;" rel="external nofollow" rel="external nofollow" >測試</a><br/><br/> <a class="layui-btn" onclick="hello('this is a test')" href="javascript:;" rel="external nofollow" rel="external nofollow" >hello</a> <script src="layui/layui.js"></script> <script type="text/javascript"> layui.use(["jquery","layer","form"],function(){ var $ = layui.$,layer = layui.layer,form = layui.form; $("#test").click(function(){ hello("張三"); }); window.hello = function(obj) { layer.msg("hello world,"+obj); } }); </script> </body> </html>
測試:
(1)點擊測試按鈕
(2)點擊 hello 按鈕
以上這篇在layui.use 中自定義 function 的正確方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript在網(wǎng)頁中畫圓的函數(shù)arc使用方法
這篇文章主要介紹了JavaScript在網(wǎng)頁中畫圓的函數(shù)arc使用方法的相關(guān)資料,需要的朋友可以參考下2015-11-11淺談 Webpack 如何處理圖片(開發(fā)、打包、優(yōu)化)
這篇文章主要介紹了淺談 Webpack 如何處理圖片(開發(fā)、打包、優(yōu)化),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-05-05javascript實現(xiàn)計算指定范圍內(nèi)的質(zhì)數(shù)示例
這篇文章主要介紹了javascript實現(xiàn)計算指定范圍內(nèi)的質(zhì)數(shù),涉及javascript數(shù)值計算與判斷相關(guān)操作技巧,需要的朋友可以參考下2018-12-12JavaScript在for循環(huán)中綁定事件解決事件參數(shù)不同的情況
響應(yīng)一堆相似的事件,但是每個事件的參數(shù)都不同,在這種情況下就可以使用JavaScript 在for循環(huán)中綁定事件,下面有個不錯的示例,大家可以參考下2014-01-01