通过javascript更改字体(不带值参数,但带文本)
我正在创建动态下拉列表,我想获取选项的名称。因为并没有我们不能使用的值通过javascript更改字体(不带值参数,但带文本),javascript,html,Javascript,Html,我正在创建动态下拉列表,我想获取选项的名称。因为并没有我们不能使用的值 document.querySelector('#hello').style.color=this.value; 所以-- A. B 你好 document.querySelector('#hello').onChange=function(){ document.querySelector('h1').style.fontSize=“120px”; document.querySelector('h1')。style.
document.querySelector('#hello').style.color=this.value;
所以--
A.
B
你好
document.querySelector('#hello').onChange=function(){
document.querySelector('h1').style.fontSize=“120px”;
document.querySelector('h1')。style.color=红色;
document.querySelector('h1').innerHTML='1222';
};
我想要的是改变h1的颜色,大小和innerHTML当选项a到b被改变时
如何使用文本b/w选项更改HELLO h1标记
a你好
b你好
分别为达到预期效果,进行以下更改 1.将onChange更改为onChange(小写)
请参阅此链接中的更改事件详细信息-
document.querySelector('#hello').onchange=function(){
document.querySelector('h1').style.fontSize=“120px”;
document.querySelector('h1').style.color='red';
document.querySelector('h1').innerHTML='1222';
};代码>
A.
B
你好
使用谷歌。有用链接:-h1是否应该根据用户选择a或b的不同而改变?或者它只是应该在任何变化时启动?
<select id="hello">
<option>a</option>
<option>b</option>
</select>
<h1>HELLO</h1>
document.querySelector('#hello').onChange=function(){
document.querySelector('h1').style.fontSize="120px";
document.querySelector('h1').style.color=red;
document.querySelector('h1').innerHTML='1222';
};