小编Sun*_*Lim的帖子

如何使这段代码简短而优化

<HTML>
<HEAD>
    <title>Login</title>
    <script type="text/javascript" src="http://script.auction.co.kr/common/jquery.js"></script>     
    <script type="text/javascript">             
    $(document).ready(function() {
        $(":input[name='txtPassword']").blur(function(e){
            $(this).css("background-color","white");
        });
        $(":input[name='txtPassword']").focus(function(e){
            $(this).css("background-color","#FDFCDC");
        });
        $(":input[name='txtID']").blur(function(e){
            $(this).css("background-color","white");
        });
        $(":input[name='txtID']").focus(function(e){
            $(this).css("background-color","#FDFCDC");
        });


    });
    </script>
</HEAD>
<body>
    <form id="Form1" method="post" runat="server">
        <div id="body">     
            <input type="text" id="txtID" name="txtID" CssClass="txt" Width="130px" tabIndex="1"></input>
            <input type="password" id="txtPassword" name="txtPassword" Width="130px" TextMode="Password" tabIndex="2"></input>
        </div>
    </form>
</body>
Run Code Online (Sandbox Code Playgroud)

这是我写的代码.

在这段代码中,我感到非常不舒服,那是因为

两个TextBox几乎相同.

但是我无法缩短这段代码.

我认为必须有最佳代码.

我知道下面的代码工作相同.但我希望附加控件名称或ID.轻松阅读代码

        $(":input").blur(function(e){
            $(this).css("background-color","white");
        });
        $(":input").focus(function(e){
            $(this).css("background-color","#FDFCDC");
        });
Run Code Online (Sandbox Code Playgroud)

javascript jquery

1
推荐指数
1
解决办法
156
查看次数

jquery选择两个条件

我想通过两个以上的条件选择一个元素.

例如

name是一些名称并已检查

我怎样才能做到这一点?

jquery

1
推荐指数
1
解决办法
1598
查看次数

为已弃用的名称创建另一个函数

class PubTools {
  void update(Context context, {bool force: false}) {
    // do something
  }
}
Run Code Online (Sandbox Code Playgroud)

是旧代码.我想将函数名称更改updateupgrade.

class PubTools {
  @deprecated
  void update(Context context, {bool force: false}) {
    upgrade(context, force);
  }
  void upgrade(Context context, {bool force: false}) {
    // do something
  }
}
Run Code Online (Sandbox Code Playgroud)

但是dartanalyzer回复警告.

就像是..

[警告]预期1个位置参数,但找到2个(/ home/sungguk/program_store/lib/grinder _utils.dart,第130行,第8列)

如何删除警告?什么是正确的语法?

dart

1
推荐指数
1
解决办法
54
查看次数

在C#try -catch中,无法捕获异常

下面的代码无法捕获异常.

确实 catch 无法赶上其发生在该函数的异常?

 try
 {
   Arche.Members.Feedback.FeedbackBiz_Tx a = 
     new Arche.Members.Feedback.FeedbackBiz_Tx();

   a.AddFreeSubscriptionMember(
     itemNo, buyerID, itemName, 
     DateTime.Today,DateTime.Today);
 }
 catch(Exception ex)
 {
   RegisterAlertScript(ex.Message);
 }
Run Code Online (Sandbox Code Playgroud)

...

public void AddFreeSubscriptionMember(
  string itemNo, string buyerID, string itemName,
  DateTime fsStartDate, DateTime fsEndDate)
{
  FeedbackBiz_NTx bizNTx = new FeedbackBiz_NTx();

  if (bizNTx.ExistFreeSubscription(buyerID, itemNo))
  {
    throw new Exception("Exception.");
  }
}
Run Code Online (Sandbox Code Playgroud)

c# try-catch

0
推荐指数
1
解决办法
2821
查看次数

在div标签中显示长文本

如果我在div中写长文本,那么长文本会超过div墙.如何将其显示为多行?

我的测试代码如下

<html>
<body>
<div style="left: 700px; top: 150px; width: 400px; height: 360px; border:1px solid">1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html css

0
推荐指数
1
解决办法
1306
查看次数

获取chrome扩展目录中所有文件的文件名?

我正在写一个chrome扩展程序,它将自定义图像添加到网页。我希望用户将所有图像都放在“ backgrounds”文件夹中,并且我希望扩展程序能够检索extensions文件夹中“ backgrounds”目录中每个文件的文件名。在chrome扩展程序中似乎无法执行此操作。当我尝试使用chrome fileSystem API时,出现以下错误:

There were warnings when trying to install this extension:
'fileSystem' is only allowed for packaged apps, but this is a extension.
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

javascript google-chrome google-chrome-extension google-chrome-app

0
推荐指数
1
解决办法
1296
查看次数