0

我想调用on focusout文本框的 javascript 函数。我有很多TextBoxes这样的方法来阻止每个监听器TextBox是否有可能在任何textBox focusout将文本框的值作为参数传递时调用相同的 javascript 方法?

我想在客户端而不是在服务器端执行此操作。

4

3 回答 3

1

使用 jQuery,它就像

$("input").focusout(function(){
    //Whatever you want
});

正如 Milney 所指出的,您可能希望与该特定文本框进行交互。为此,您可以使用“$(this)”作为选择器。

$("input").focusout(function(){
    $(this).css("background-color", "beige");
});
于 2017-02-13T12:46:31.663 回答
0

当字段失去焦点时会发生模糊事件。

尝试这个:

$("input").blur(function(){
 //alert("ok")
});
于 2017-02-13T12:50:14.137 回答
0

利用

$("input").focusout(function(){
  var tBval = $(this).val();
  console.log(tBval);
  
  // OR Call a function passing the value of text box as parameter
  //myFunction(tBval);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />

于 2017-02-13T12:53:44.467 回答