Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript更改字体(不带值参数,但带文本)_Javascript_Html - Fatal编程技术网

通过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('h1').style.color='red'
  • 代码笔供参考-

    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';
    
               };