简体   繁体   English

JS更改img标签

[英]JS to change img tag

I have a bunch of java-script in one page. 我在一页中有一堆Java脚本。 Working (this time :) ) 工作(这次:))

When I add the following simple code everything stops working, is there a small type or something I am missing? 当我添加以下简单代码时,所有内容都会停止工作,是否存在小型字体或缺少的内容?

if(document.getElementById('checkBottom').checked)
{
     document.getElementById('preview_hl_front').src = "./assets/images/bottom---highligt-front.png";
{
else
{
     document.getElementById('preview_hl_front').src = "./assets/images/highligt-front.png";
}

Other components: 其他组件:

<input type="checkbox" name="bottom" id="checkBottom" value="yes" data-preview="preview_bottom" onclick="validate()">

    <div class="panel panel-default">
        <div id="preview">
        <img src="./assets/images/highligt-front.png" id="preview_hl_front" />
        </div>
    </div>

You have a typo. 你有错字 you closed the if block with { instead of } 您用{而不是}关闭了if
Change this: 更改此:

if(document.getElementById('checkBottom').checked)
{
     document.getElementById('preview_hl_front').src = "./assets/images/bottom---highligt-front.png";
{

To this: 对此:

if(document.getElementById('checkBottom').checked)
{
     document.getElementById('preview_hl_front').src = "./assets/images/bottom---highligt-front.png";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM