如何动态地将参数传递给javascript方法 [英] How to pass parameters to javascript method dynamically

查看:58
本文介绍了如何动态地将参数传递给javascript方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示通知的javascript函数



 function (){
$(' 。demo-1')。on( ' 点击'功能(e) {
e.preventDefault();
$ .notify(' 我是一个警告框。 ');
});
})(jQuery);





我尝试了什么:



我想将动态值传递给它,为此,我已按如下方式自定义上述代码:



 function  ShowNotification(message){
$ .notify(消息);
})(jQuery);





Javascript代码不起作用,任何人都可以帮我解决这个问题吗?


谢谢

解决方案

' < span class =code-string>。demo-1')。on(' click' function (e){
e.preventDefault();


.notify(' 我是一个警报框。');
});
})(jQuery);





我尝试过:



我想将动态值传递给它,为此,我已按照以下方式自定义上述代码:



< pre lang =Javascript>( function ShowNotification(message){


.notify(message);
} )(jQuery);





Javascript代码无效,任何人都可以帮我解决这个问题吗?



谢谢


I have got a javascript function which displays the notification

(function () {
      $('.demo-1').on('click', function (e) {
         e.preventDefault();
         $.notify('I am a alert box.');
       });
     })(jQuery);



What I have tried:

I want to pass dynamic values to it and for that, I've customized the above code as follows:

(function ShowNotification(message) {
      $.notify(message);
})(jQuery);



Javascript code is not working, can anyone help me fix this issue?

Thanks

解决方案

('.demo-1').on('click', function (e) { e.preventDefault();


.notify('I am a alert box.'); }); })(jQuery);



What I have tried:

I want to pass dynamic values to it and for that, I've customized the above code as follows:

(function ShowNotification(message) {


.notify(message); })(jQuery);



Javascript code is not working, can anyone help me fix this issue?

Thanks


这篇关于如何动态地将参数传递给javascript方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆