在layui.use中自定義function的正確方法

適用于:

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供東昌網(wǎng)站建設(shè)、東昌做網(wǎng)站、東昌網(wǎng)站設(shè)計(jì)、東昌網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、東昌企業(yè)網(wǎng)站模板建站服務(wù),10余年東昌做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

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" >測(cè)試</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>

測(cè)試:

(1)點(diǎn)擊測(cè)試按鈕

在layui.use 中自定義 function 的正確方法

(2)點(diǎn)擊 hello 按鈕

在layui.use 中自定義 function 的正確方法

以上這篇在layui.use 中自定義 function 的正確方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持創(chuàng)新互聯(lián)。

分享標(biāo)題:在layui.use中自定義function的正確方法
網(wǎng)頁(yè)地址:http://muchs.cn/article30/gppcpo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、微信公眾號(hào)、移動(dòng)網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、網(wǎng)站排名虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司