使图像显示在jsp中

时间:2014-07-14 19:01:37

标签: html css jsp

我目前有一个jsp,在m html部分我有以下

<select>
<%if(size == 1)%>
  <option>None selected</option>
<%if(size > 1)%>
  <option>1</option>
</select>

我也有以下图片。

<td style="text-align:left">
            <label id="checked" style="color:grey; display:none">
                <img src="images/check.png" width="20px" height="20px"/>
                Checked
            </label>
        </td>

我的问题是,如果选择无选项,我该如何才能显示图像。如果选择1,那么我不希望图像出现。我该怎么做?

1 个答案:

答案 0 :(得分:0)

我认为,这将为您解决问题,我在这里使用了JQUERY。

 $("#selectID or .selectClass").change(function () { //just use id or class name for select element

    var option=$(this).val();
    if(option=="None selected")
    {
      $("#checked").css("display","block");

    }
    else
    {
       $("#checked").css("display","none");
    }      

});