Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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_Css - Fatal编程技术网

Javascript 如何使特定的输入触发某些东西?

Javascript 如何使特定的输入触发某些东西?,javascript,html,css,Javascript,Html,Css,我正在尝试做一个函数,当一个人输入一个0和8之间的数字,然后发生与该数字对应的事情时进行检查。例如,用户输入5,这使得出现图片和文本,如果用户输入3,则出现不同的图片和文本等 到目前为止,我有一个论坛,人们可以输入一个数字,但我一直在想如何让这些输入触发显示图片和文本的动作 <div id="Jupiter"> <div class="pictures" > <img src="img/Jupi

我正在尝试做一个函数,当一个人输入一个0和8之间的数字,然后发生与该数字对应的事情时进行检查。例如,用户输入5,这使得出现图片和文本,如果用户输入3,则出现不同的图片和文本等

到目前为止,我有一个论坛,人们可以输入一个数字,但我一直在想如何让这些输入触发显示图片和文本的动作

<div id="Jupiter">
                <div class="pictures" >
                    <img src="img/Jupiter.gif">
                </div>
                    <h1 class="title">Jupiter</h1>
                    <div class="paragraphs"><p> Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a giant planet with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter and Saturn are gas giants; the other two giant planets, Uranus and Neptune, are ice giants. Jupiter has been known to astronomers since antiquity.[17] It is named after the Roman god Jupiter.[18] When viewed from Earth, Jupiter can reach an apparent magnitude of −2.94, bright enough for its reflected light to cast shadows,[19] and making it on average the third-brightest natural object in the night sky after the Moon and Venus. <br><br>Jupiter is primarily composed of hydrogen with a quarter of its mass being helium, though helium comprises only about a tenth of the number of molecules. It may also have a rocky core of heavier elements,[20] but like the other giant planets, Jupiter lacks a well-defined solid surface. Because of its rapid rotation, the planet's shape is that of an oblate spheroid (it has a slight but noticeable bulge around the equator). The outer atmosphere is visibly segregated into several bands at different latitudes, resulting in turbulence and storms along their interacting boundaries. A prominent result is the Great Red Spot, a giant storm that is known to have existed since at least the 17th century when it was first seen by telescope. Surrounding Jupiter is a faint planetary ring system and a powerful magnetosphere. Jupiter has 79 known moons,[21] including the four large Galilean moons discovered by Galileo Galilei in 1610. Ganymede, the largest of these, has a diameter greater than that of the planet Mercury.<br><br>Jupiter has been explored on several occasions by robotic spacecraft, most notably during the early Pioneer and Voyager flyby missions and later by the Galileo orbiter. In late February 2007, Jupiter was visited by the New Horizons probe, which used Jupiter's gravity to increase its speed and bend its trajectory en route to Pluto. The latest probe to visit the planet is Juno, which entered into orbit around Jupiter on July 4, 2016.[22][23] Future targets for exploration in the Jupiter system include the probable ice-covered liquid ocean of its moon Europa.</p>
                </div>
        </div>
我理解了如何获取函数,但我困惑的是如何准确地显示div id Jupiter。这是我最初的问题,很抱歉误解了。

您可以收听“来自输入框”的内容

函数onKeyUp(e){
if(parseInt(e.value)==5){
//在这里做点什么
}
}
您需要使用DOM

函数操作(){
var data=document.getElementById(“结果”).innerHTML;//获取数据
如果(数据==1){
警报(“1”);
}
}

了解事件处理。具体在哪里?处理事件?知道要处理哪个事件?获取价值观?比较价值观?请尽可能包含您的最佳尝试代码,确保也包含相关的HTML。我不知道如何在输入数字时使图片实际显示。如果我不得不冒险猜测,那可能是因为有人认为回答如此糟糕的问题不合适。是的,我想帮忙,但在我回答问题后不久,我就看到了对这个问题的反对票。下次我们会“小心”的。主要的问题是我们不想鼓励研究不足的问题。在不鼓励更多的情况下,我们有足够多的问题需要处理。答案应该根据其本身的优点进行投票,而不管问题的质量如何。在某个地方有一个关于这个主题的元帖子。
<fieldset>
            <legend>Enter a Number between 0 and 9</legend>
            <p>Number: <input type="text" id="inputNumber" placeholder="Number" required></p>
            <p><input type="submit" value="Enter" id="submit" /></p>
        </fieldset>
function displayPlanet(){
        var data = getElementbyId("submit").innerHTML;
        if(data == 5){

        }
    }