Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.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
Html 单击按钮时出现的图像_Html_Image_Button_Click_Hidden - Fatal编程技术网

Html 单击按钮时出现的图像

Html 单击按钮时出现的图像,html,image,button,click,hidden,Html,Image,Button,Click,Hidden,单击“提交”按钮时,如何使隐藏图像显示?这取决于您如何隐藏它。最简单的方法是将图像的类名从隐藏改为不隐藏 <img src="thesource" class="hidden"> document.getElementById("theid").className = ""; // remove the hidden class. .classHidden { display: none; } document.getElementById(“theid”).cl

单击“提交”按钮时,如何使隐藏图像显示?

这取决于您如何隐藏它。最简单的方法是将图像的类名从隐藏改为不隐藏

<img src="thesource" class="hidden">

document.getElementById("theid").className = ""; // remove the hidden class.


.classHidden {
     display: none;
}

document.getElementById(“theid”).className=“”;//删除隐藏的类。
.classHidden{
显示:无;
}

你很幸运,我准备了一个空白的HTML页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" /> 
    <meta charset="utf-8" />

    <title>Test</title>

    <style type="text/css">
      .hidden {
        display: none;
      }
    </style>
  </head>

  <body>
    <form>
      <input type="submit" id="submit" onclick="document.getElementById('hidden').style.display = 'block';" />
     </form>

     <img id="hidden" class="hidden" src="foo.png" />
  </body>
</html>

试验
.隐藏{
显示:无;
}
以下是一个示例

<img class="image_file src="image.jpg" />
<input type="submit" id="submit_button" name="submit_button" />
使用jquery:

$('#submit_button').click(function(
    $('.image_file').show();
));
尽量避免使用内联javascript,当你有一个大的网站时,它会很混乱并且很难维护。

使用jQuery:

<img id="image1" src="myimage.jpg" style="display:none;" width="120" height="120"/>

<input type="submit" name="submit" value="submit" onclick"$('#image1').show()"/>

如何隐藏图像?您使用的是jQuery、Mootools或Prototype之类的javascript框架吗?
$('#submit_button').click(function(
    $('.image_file').show();
));
<img id="image1" src="myimage.jpg" style="display:none;" width="120" height="120"/>

<input type="submit" name="submit" value="submit" onclick"$('#image1').show()"/>