当我将鼠标悬停在按钮上时,使用javascript或CSS更改输入区域的颜色? 提交 document.getElementById(“b1”).hover=function(){ document.getElementById(“b2”).style.color=“蓝色”; }; id为b2的输入 id为b1的按钮 将鼠标悬停在b1,更改b2

当我将鼠标悬停在按钮上时,使用javascript或CSS更改输入区域的颜色? 提交 document.getElementById(“b1”).hover=function(){ document.getElementById(“b2”).style.color=“蓝色”; }; id为b2的输入 id为b1的按钮 将鼠标悬停在b1,更改b2,javascript,html,css,Javascript,Html,Css,给您: document.getElementById('b1').onmouseover=function(){ document.getElementById('b2').style.color='red'; }; 提交 类似的方法应该可以: HTML <form> <input id="b2" type="text" placeholder="Enter Name." name="name" maxlength="300"> <br>

给您:

document.getElementById('b1').onmouseover=function(){
document.getElementById('b2').style.color='red';
};


提交
类似的方法应该可以:

HTML

<form>
    <input id="b2" type="text" placeholder="Enter Name." name="name" maxlength="300">
    <br>
    <button id="b1" type="button name" >Submit</button>
</form>
<script> 
    document.getElementById("b1").hover = function() {
        document.getElementById("b2").style.color="blue";
    }; 
</script>
鼠标悬停时执行,未被覆盖时停止

试试这个

$("#b1").mouseover(function() {
    $("#b2").css("color","red");
});

这是你到目前为止所做工作的JS代码。document.getElementById(“b1”).hover=function(){document.getElementById(“b2”).style.color=“blue”};我发现我可以将鼠标悬停在一个按钮上,然后使用纯css更改另一个按钮上的css#button1:hover+#button2{border:solid 1px#ccc;}但是不知道如何对输入进行更改可能这会很有用:谢谢你,阿富科,你的链接非常有用。@Chris:请接受并投票支持我。谢谢。嘿,珍,这个看起来也很不错。
$("#b1").hover(function() {
    $("#b2").css("color","red");
});
$("#b1").mouseover(function() {
    $("#b2").css("color","red");
});
<form>
<input id="b2" type="text" placeholder="Enter Name." name="name" maxlength="300">

<button id="b1" type="button name" >Submit</button>
</form>
$("#b1").hover(function(){
  $('#b2').css("background-color", "yellow");
}, function(){
$('#b2').css("background-color", "pink");

 });