如下所示,在codeigniter视图中,我想调用两次js事件-“ onchange”和“ onblur”函数
有可能吗?我怎么打电话?
答案 0 :(得分:1)
请参见下面的代码。
<html>
<bods >
<input type="text" value="here is a text field" onblur="alert('Blur Event!')" onchange="alert('Change Event!')" >
</body>
</html>
答案 1 :(得分:0)
这两种方法将同时调用,我不确定您出于什么目的需要它。 但是您可以编写以下两种方法。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("input").change(function(){
alert("The text has been changed.");
});
$("input").blur(function(){
alert("This input field has lost its focus.");
});
});
</script>
</head>
<body>
<input type="text">
<p>Write something in the input field, and then click outside the field.</p>
</body>
</html>
答案 2 :(得分:0)
<!DOCTYPE html>
<html>
<body>
Enter your name: <input type="text" id="fname" onKeyUp="keyupcall()" onblur="blurfunction()">
<script>
function blurfunction() {
var x = document.getElementById("fname");
x.value = x.value.toLowerCase();
}
function keyupcall(){
var x = document.getElementById("fname");
x.value = x.value.toUpperCase();
}
</script>
</body>
</html>