Javascript 将鼠标悬停在ng上的文本上禁用输入为文本框
我有两个这样的文本框,只要你在textbox1中输入一些文本,textbox2就会被禁用,这是有效的。第二个要求是,禁用后,当鼠标悬停在第二个文本上时,它应该显示您只能在一个文本框中输入的内容 有人能帮我一下吗?这里是代码:Javascript 将鼠标悬停在ng上的文本上禁用输入为文本框,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我有两个这样的文本框,只要你在textbox1中输入一些文本,textbox2就会被禁用,这是有效的。第二个要求是,禁用后,当鼠标悬停在第二个文本上时,它应该显示您只能在一个文本框中输入的内容 有人能帮我一下吗?这里是代码: <html> <body> <input type="text" id="firstbox" onmouseleave="disablesecond(3)" onmouseover="disablesecond(2)"> <inp
<html>
<body>
<input type="text" id="firstbox" onmouseleave="disablesecond(3)" onmouseover="disablesecond(2)">
<input type="text" id="second" onmouseleave="disablesecond(3)" onmouseover="disablesecond(1)">
<p id="info"></p>
<script>
function disablesecond(needtoblock){
if(needtoblock == 1){
document.getElementById("firstbox").disabled = true;
document.getElementById("second").disabled = false;
document.getElementById("info").innerHTML= "Only one box!";
}else if(needtoblock == 2){
document.getElementById("second").disabled = true;
document.getElementById("firstbox").disabled = false;
document.getElementById("info").innerHTML= "Only one box!";
}else{
document.getElementById("firstbox").disabled = false;
document.getElementById("second").disabled = false;
document.getElementById("info").innerHTML= "";
}
}
</script>
</body>
</html>
这是我的解决方案,您必须将ng禁用,条件为firs要求,输入标题为angularjs表达式: html
这是代码笔如果条件允许,您是否有可能帮我对ng进行同样的操作请。。。。。我真的很感谢你的时间,不过…@Krishna,你可以把它改成你的代码,这个想法已经给出了。
<div ng-app="myApp">
<div ng-controller="validateController as vm">
<input type="text" ng-model="vm.first" >
<input type="text" ng-model="vm.second"
ng-disabled="!!vm.first" title="{{vm.first ? 'You can enter only in one textbox': ''}}">
</div>
</div>
(function(){
angular.module('myApp',[]);
})();
(function(){
angular.module('myApp')
.controller('validateController',validateController);
function validateController(){
var vm = this;
}
})();