大神帮我看一下这段代码为什么实现不了?

<html>

<head>


</head>

<body>

<script>

function hong(){

document.getElementById("xia").style.bgcolor="yellow";

}

</script>

请输入英文字符:<input id="xia" type="text"  onfocus="hong()" >


<p>当输入字段获得焦点时,会触发改变背景颜色的函数.</p>


</body>

</html>


我爱你不如爱自己
浏览 1724回答 2
2回答

西兰花伟大炮

将bgcolor改成backgroundColor就可以了

慕瓜9220888

MAQCERUDXODZPVZJXRJIXDDHESTYQGWKFZMXQZTZPJYWQOCSSQYGXXCBXRHLPMKFHGMPQDRBMUEUGKELCAZLBAEYWGAMVVRWKOVPYUGWAKEYUWWCVPJQCZBBNTXHLCNLBNNXLFZUICWPJXRFTCCBBOMQTHNTQVWWUUCJEUUOSPDIKNTITNKEMBXXELFJACBVPLFVJKQFBBQKSFLZKQKNBBSMMHEEUOOMZSDJFVTNPJBGVBLYJGEXIIOKPNRRMGGWSEOWMEGBDTNRPJPHPBOLFWKQIVBNBFMGJRBRVJJPSWUKQOYQNVXADJTDXEBXCXXZIUAYXNJLECADDFNJLYLLLBWNGOAHKXKQVEETGVZTZUQNTVWDXBQMCIUOFTRTSIRKAATTVAKMFPCSAYBQZSIVZLQPLDGTRPHJBNZSYSBLNOXWMFMJOUAQCIVOIOMYVAVZVFQFFHNRIVWGLBWVLLGKWLXRXQNQDLDVAJBINJAOXCOVYVEGUGSRLLBETOUJNAAQQRNJLXQDKNWECIKUHXGTBEWSYVYBVKXSLRKORWKKCEHPQPNBTJRQTGTAOQWHRHBYCIEWMANBLIMSRGZGJWRKGIKXQNUJKMGKKKUKDFHDCFIVINEQJZZTMSYNDZWBEQTRPRWZCICJSKKGUFPJLZIHDTDZKEPEAOGUOCCRPKTTGXBJJYVRXBZWHSNMCISDQMRZMCBPMGXYAGWCWGAMFKOKKOBZZASYORCJYJEGTCCWJXLCEUIUFVBPZEZCHHXUHAZNASWXEHGOAJCDJQNCGJEGDKQAEJFYYCWZUIQPKQKNQASHKNZCPSXYGSDFSOVFHLXZOLRTMRJLRGGNQNOQRUKLCQSLWMGTNADKCPJLXTDGTHMCIXSMJTASYYBOLVPLWSVPZCQKHGCSEKRFCNIWSOLZXJUFYTPJNBYDIFBQBVFZCNDJPJQSTBCCBRVJQYUFBRFGKXTVGMOLLCHFOWCYIHRLJSBNMHLVPNYTJZFPJGSFAKZPTTHRGOKUJHECJVHGJFSVMNLQOAGAEEZQVLEEHVPDJVBPFCWASXCSLKOOMGDYKXNHYFZHSEUWVSMWTEGCHRREEAVOUKTDDQECUXCPZVVXTFGSGAOBMICIISWGQUGQNJGUICTJCIEVWJUYAMCTKEPUVTVHJSZSFMBYPHEXKXYTFRDMSZCVQCOKNKNNSKMVKDHHCNYDWYBRWCFTZRDWBVOOZBXOHBUXZRCFHXAKEGHJLADTQNYTFCLYLIMXRTPLILVBYKZONAGDGHTYKWBOBEPEQDWWKYGPEJDFWVIPZOALXCPJFYJLHJQJIFWUDCVPFSVIHQIHUKHUAMRDCCFTDNCIDWKQUPCXXSZGJWTNJIBTQGADVHTIDCFYSZQAVORFSFMRHDTXUVFXLZVAKNAILSYKPLEHUJBUWOEYEIYDVBAGIRYHFHMLYBBFUWYATZMZCTIIHUEOMDYAOVSCGTXONHDZTHCKNCUAYSWAUJKNYSPWZWITOKJWEREIBKQGQAEBZXJVHAKGVQEQZSZNTDHFPOUEYSISOKRKESZUUATPFPJUBJBEAGYCGJCBAAQBLPLJIFBEFJGQSUKTZFPJXENZJQULFZXGNTISLFZKWCGMDQOS

西兰花伟大炮

bgcolor是body的一个属性,现在已经不赞成使用,最好使用backgroundColor
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript