JQuery Показать Скрыть Выбор блока опций - PullRequest
1 голос
/ 06 марта 2012
<div class="langs">
    <div class="flag"><h3>Country</h3>
       <img id="flag" src="../media/images/flags/en.png"/>
    </div>
   <select class="select_country" name="country" id="select_country">
   <option>United States</option>
   <option>Spain</option>
   <option >France</option>
   </select>
   </div>

Jquery:

    $(".langs").hover(function() {
    $("#select_country").slideToggle('500').css({"display":"block"});

    });

Я не буду при наведении мыши показывать блок выбора, а после выбора страны скрывать блок выбора.

Ответы [ 2 ]

0 голосов
/ 06 марта 2012
//By default hide the select box
$("#select_country").hide();

//On mouseover it will show the select box
$(".langs").mouseover(function() {
    $("#select_country").show();
});

//Once you change the selection it will hide itself
$("#select_country").change(function(){
    $(this).hide();
});
0 голосов
/ 06 марта 2012

Как то так?

$(".langs").mouseenter(function() {
    $("#select_country").show(); // SHOW #select_country on mouse over
});

$(".langs").mouseleave(function() {
    $("#select_country").hide(); // HIDE #select_country on mouse out
});

Вы также можете использовать .slideDown () и .slideUp () вместо .show () и .hide ()

Пример: http://jsfiddle.net/xUWK6/1/

...