javascript - Dropdown on click of image -


i want open dropdown on click of image , display alert message of dropdown option being clicked .

my html code :

<div class="account_notification"> <a href="#"> <div class="notify_notification">click</div><!-- notify_notification close --></a> </div><!-- account_notification close --> <select class="select1" size="5" style="display:none">             <option name="test" value="" class="first">select</option>            <option name="test" value="" class="">notification1</option>            <option name="test" value="" class="">notification2</option>  </select> 

what javascript code ?

though found jquery on inernet dropdown display without showing option selected , know little jquery .so want code in javascript.please help

jquery found follow :

$('.notify_notification').click(function() {     $('.select1').toggle(); }); 

i got code answers problem here suppose before click if bar this:

http://postimg.org/image/n04ggm7ux/

after clicking image bar become :

http://postimg.org/image/4h344hl7t/

how down instead of being displayed along side ?

  1. if want open dropdown, not unhide select element... well, you're in trouble, because there no generic or simple solution that. consider building custom drop-down, trying elements (like radio buttons) or using shadow dom.

  2. to show selected option, use this:

    alert($('.select1 option:selected').text()); //show text of selected option alert($('.select1').val()); //show selected value 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -