第二JavaScript的code总是覆盖第一 [英] Second JavaScript code is always overriding the first

查看:87
本文介绍了第二JavaScript的code总是覆盖第一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的2个独立的JavaScript参...见下文......

I am using 2 separate JavaScript refs...see below...

    <script src="../scripts/jsKeyboard.js" type="text/jscript"></script>
<script src="../scripts/DOB_Validate.js" type="text/jscript"></script>

我通过使用两个单独的ASP的onfocus事件调用每个使用Javascript:文本框......请看下图:

I am calling each Javascript through an onfocus event using two seperate asp:Textbox...see below:

<asp:Textbox id="txtFirstName" runat="server" onfocus="jsKeyboard.focus(this);clean(this);" placeholder="Touch Here To Enter First Name" autofocus top="50%"></asp:Textbox>

    <asp:TextBox ID="TextBox1" runat="server" onfocus="board.focus(this);clean(this);" placeholder="MM/DD/YYYY" 
 maxlength="10" Width="5%"></asp:TextBox>

我在页面的脑袋里面两个脚本具有相应的.js外部引用(见上面两个独立的.js脚本)...

I have two scripts inside the head of the page that initialize the keyboard with the corresponding .js external ref (see two separate .js scripts above)...

里面的头脚本:

    <script type="text/javascript">
    $(function () {
        board.init("virtualKeyboard");
    });
 </script>

 <script type="text/javascript">
     $(function () {
         jsKeyboard.init("virtualKeyboard");
     });
 </script>

不过......在头内的第二个脚本总是覆盖其他...

However...the second script inside the head is always overriding the other...

我怎样才能解决这个问题?谢谢...

How can I fix this issue??? Thank you...

推荐答案

您的两个功能长得一模一样。我会假设你希望两个相同的功能?如果是这样的话,你是挂接到同一元素txtContent。你需要有其他的脚本勾成TextBox1的。

Both of your functions look exactly the same. I am going to assume you want the same functionality for both? If that's the case, you are hooking into the same element 'txtContent'. You need to have the other script hook into 'TextBox1'.

有关txtContent:

For txtContent:

 <script type="text/javascript">
         $(function () {
             jsKeyboard.init("virtualKeyboard");
             $("#txtContent").val(initText);
         });

     </script>

和TextBox1的:

And TextBox1:

   <script type="text/javascript">
      $(function () {
          board.init("virtualKeyboard");
          $("#TextBox1").val(initText);
      });

 </script>

您可能还需要考虑改变TextBox1的名称。

You also may want to consider changing the name of TextBox1.

这篇关于第二JavaScript的code总是覆盖第一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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