在javascipt函数中调用jquery插件 [英] call jquery plugin in javascipt function

查看:76
本文介绍了在javascipt函数中调用jquery插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在JavaScript函数onclick上调用jquery插件,首先告诉我如何创建名称为="model"和href =#dialog"的锚标记来调用jquery
如下面的代码
然后如何在jquery中使用它




I want to call the jquery plug in on javascript function onclick,first tell me how to create anchor tag with name ="model" and href="#dialog" to call the jquery
as in the code below
then how to use it with the jquery


function CallOnClick() {

          debugger

          var elem = document.getElementsByTagName('a');
          elem.Name = "modal";
               elm.href="#dialog";
          //select all the a tag with name equal to modal
          $('a[name=modal]').click(function(e) {
              //Cancel the link behavior

              e.preventDefault();

              //Get the A tag
              var id = $(this).attr('href');

              //Get the screen height and width
              var maskHeight = $(document).height();
              var maskWidth = $(window).width();

              //Set heigth and width to mask to fill up the whole screen
              $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

              //transition effect
              $('#mask').fadeIn(1000);
              $('#mask').fadeTo("slow", 0.8);

              //Get the window height and width
              var winH = $(window).height();
              var winW = $(window).width();

              //Set the popup window to center
              $(id).css('top', winH / 2 - $(id).height() / 2);
              $(id).css('left', winW / 2 - $(id).width() / 2);

              //transition effect
              $(id).fadeIn(2000);

          });

          //if close button is clicked
          $('.window .close').click(function(e) {
              //Cancel the link behavior
              e.preventDefault();

              $('#mask').hide();
              $('.window').hide();

          });

      }
  </script>

推荐答案

(' a [name = modal]').click(函数(e){ // 取消链接行为 e.preventDefault(); // 获取A标签 var id =
('a[name=modal]').click(function(e) { //Cancel the link behavior e.preventDefault(); //Get the A tag var id =


( this ).attr(' href'); // 获取屏幕的高度和宽度 var maskHeight =
(this).attr('href'); //Get the screen height and width var maskHeight =


( document ).height(); var maskWidth =
(document).height(); var maskWidth =


这篇关于在javascipt函数中调用jquery插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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