开发者

HTML select options close div

开发者 https://www.devze.com 2023-02-01 07:45 出处:网络
I\'m new to JavaScript, so this might be very easy for a lot of you. I have a HTML select object with some options in it. The whole SELECT is in a small div. The only thing I like to achieve is to cl

I'm new to JavaScript, so this might be very easy for a lot of you.

I have a HTML select object with some options in it. The whole SELECT is in a small div. The only thing I like to achieve is to close the div everytime I clock on one of the options. Now, every option does something else, that's no problem. But I can't seem to tell all of them to close this div. Is it somet开发者_如何学Gohing about this.id ??

Thanks


give id to that div...for my example suppose it is 'Div' and try this code...
<form name='template'> <select name='choise' onchange="javascript:hideDiv()">
<option value="uniquename">uniquename</option>
</select>
</form>

and script code is
function hideDiv(){
if(document.getElementById('Div').style.display != "none") { document.getElementById('Div').style.display = "none"; }}

0

精彩评论

暂无评论...
验证码 换一张
取 消