如何从Java脚本中的另一个函数调用函数

问题描述:

我有一个函数,如果我把它叫做jquery事件按键按下,它就可以正常工作。但是如果我从另一个函数调用相同的函数,它不起作用。 这样的调用乘法函数里面添加。如何从Java脚本中的另一个函数调用函数

function add(){ 
    multiply(); 
    } 

的javascript:

 $(function(){ 

      var input = $('.input'), 
     bar = $('.bar'), 
     bw = bar.width(), 
     percent = bar.find('.percent'), 
     ps = percent.find('span'), 
     name = 'rotate'; 

     input.on('keydown', function(e){ 
     if (e.keyCode == 13){ 
      var t = $(this), val = t.val(); 
      if (val >=0 && val <= 100){ 
       var w = 100-val, pw = (bw*w)/100, 
        pa = { 
         height: w+'%' 
        }, 
        cw = (bw-pw)/2, 
        ca = { 
         left: cw 
        } 
       ps.animate(pa); 
       cs.text(val+'%'); 
       circle.animate(ca, function(){ 
        circle.removeClass(name) 
       }).addClass(name); 
      } else { 
       alert('range: 0 - 100'); 
       t.val(''); 
      } 
     } 
    }); 

}); 

HTML:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <title>Horizontal bar graph with CSS3 and jQuery</title> 
     <link href="css/default.css" rel="stylesheet" type="text/css" /> 
     <script src="js/jquery.js" type="text/javascript"></script> 
     <script src="js/init.js" type="text/javascript"></script> 
     <script src="slider_scripts/cal_impact_on_clinic.js"></script> 
     <style> 
     #sliderValue140h{ position:absolute; 
      margin:0px 0px 0px 330px; 
      font-family: Myriad Pro,Normal,strong; 
      font-size: 16px; 
      border:none; 
      background-color:transparent; 
      color:#000; 
      } 

      #sliderValue150h{ position:absolute; 
      margin:0px 0px 0px 330px; 
      font-family: Myriad Pro,Normal,strong; 
      font-size: 16px; 
      border:none; 
      background-color:transparent; 
      color:#000; 
      }  

      #sliderValue160h{ position:absolute; 
      margin:0px 0px 0px 330px; 
      font-family: Myriad Pro,Normal,strong; 
      font-size: 16px; 
      border:none; 
      background-color:transparent; 
      color:#000; 
      }      
     </style> 


     <script language="JavaScript" src="slider_scripts/slider.js"></script> 
     </head> 

     <body> 
     <form action="#" method="get" name="demoForm" id="slider"> 

     <div id="sliderimpact2_slide2" ontouchmove="calc(),put_zero();"> 

     <input name="sliderValue" type="Text" id="sliderValue140h" onChange="A_SLIDERS[5].f_setValue(this.value)" value="5" size="3" readonly> 

     <script language="JavaScript"> 

    var A_TPLh140h = { 

    'b_vertical' : false, 

    'b_watch': true, 

    'n_controlWidth': 356, 

    'n_controlHeight': 29, 

    'n_sliderWidth': 32, 

    'n_sliderHeight': 33, 

    'n_pathLeft' : -5, 

    'n_pathTop' : -8, 

    'n_pathLength' :340, 

    's_imgControl': 'images/slide5slider.png', 

    's_imgSlider': 'images/Slider Circle 2.png', 

    'n_zIndex': 1 

     } 




     var A_INITh140h = { 

    's_form' : 0, 

    's_name': 'sliderValue140h', 

    'n_minValue' : 0, 

    'n_maxValue' : 100, 

    'n_value' : 0, 

    'n_step' : 5, 

     } 


     new slider(A_INITh140h, A_TPLh140h); 

      </script> 

      </div> 
      <br /> 
      <br /> 

      <div id="sliderimpact2_slide2" ontouchmove="calc(),put_zero();"> 

      <input name="sliderValue" type="Text" id="sliderValue150h" onChange="A_SLIDERS[5].f_setValue(this.value)" value="5" size="3" readonly> 

      <script language="JavaScript"> 

     var A_TPLh150h = { 

    'b_vertical' : false, 

    'b_watch': true, 

    'n_controlWidth': 356, 

    'n_controlHeight': 29, 

    'n_sliderWidth': 32, 

    'n_sliderHeight': 33, 

    'n_pathLeft' : -5, 

    'n_pathTop' : -8, 

    'n_pathLength' :340, 

    's_imgControl': 'images/slide5slider.png', 

    's_imgSlider': 'images/Slider Circle 2.png', 

    'n_zIndex': 1 

     } 



      var A_INITh150h = { 

    's_form' : 0, 

    's_name': 'sliderValue150h', 

    'n_minValue' : 0, 

    'n_maxValue' : 100, 

    'n_value' : 0, 

    'n_step' : 5, 

     } 

     new slider(A_INITh150h, A_TPLh150h); 

      </script> 

      </div> 
      <br /> 
      <br /> 





    <div id="sliderimpact2_slide2" ontouchmove="calc(),put_zero();"> 

    <input name="sliderValue" type="Text" id="sliderValue160h" onChange="A_SLIDERS[5].f_setValue(this.value)" value="5" size="3" readonly> 

    <script language="JavaScript"> 

var A_TPLh160h = { 

    'b_vertical' : false, 

    'b_watch': true, 

    'n_controlWidth': 356, 

    'n_controlHeight': 29, 

    'n_sliderWidth': 32, 

    'n_sliderHeight': 33, 

    'n_pathLeft' : -5, 

    'n_pathTop' : -8, 

    'n_pathLength' :340, 

    's_imgControl': 'images/slide5slider.png', 

    's_imgSlider': 'images/Slider Circle 2.png', 

    'n_zIndex': 1 

    } 



     var A_INITh160h = { 

    's_form' : 0, 

    's_name': 'sliderValue160h', 

    'n_minValue' : 0, 

    'n_maxValue' : 100, 

    'n_value' : 0, 

    'n_step' : 5, 

     } 

     new slider(A_INITh160h, A_TPLh160h); 

      </script> 

      </div> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 
      <br /> 

      <img src="images/Show Impact.png" onclick="slidercalsevere();"> 
      <div class="wrap"> 
    <div class="bar"> 
    <div class="percent"> 
    <span style="width: 100%;"></span> 
    </div> 
    </div> 

      <div class="text"> 
    <input type="text" class="input" value="0" id="sliderValue170h"/> 
    </div> 
    </div> 
      </form> 
      </body> 
      </html> 

这里是单独的HTML文件只

http://pastebin.com/rsDuEWf3

这里是脚本音响乐

http://pastebin.com/Sev6yTnb

+0

由于缺乏大写和标点符号以及大量无关代码,因此很难理解您的问题。见[问]。 – Antony 2013-04-04 09:00:26

+0

您是否介意在提出问题之前删除不相关的CSS,标记并将源代码截断为单个文件? – neuront 2013-04-04 09:01:23

+0

“它不工作”是*永远不是一个适当的问题/错误描述。请具体说明您的问题:您希望发生什么?发生了什么?你的[调试尝试]结果是什么(http://www.netmagazine.com/tutorials/javascript-debugging-beginners)? – 2013-04-04 09:01:28

如果要加载的页面使用的加载功能的window.onload =增加;