>  기사  >  웹 프론트엔드  >  JS를 사용하여 드롭다운 상자 기능 구현

JS를 사용하여 드롭다운 상자 기능 구현

php中世界最好的语言
php中世界最好的语言원래의
2018-04-19 13:38:081840검색

이번에는 JS를 사용하여 드롭다운 상자 기능을 구현하는 방법에 대한 Notes를 소개하겠습니다.

  ="content-type"content=>  =>
    *{padding: 0;margin:0;}
    ul,li{list-style: none}
    .left{float: left;}
    .right{float: right;}
    .select_contain{font-size: 14px;color: #333;line-height: 38px;margin: 30px 0;}
    .select_item{margin-right: 50px;position: relative;}
    .select_tit{margin-right: 20px;}
    .select_result{width:  100px;line-height: 38px;border:1px solid #ccc;text-align:  center;border-radius: 4px;text-indent: -8px;cursor:pointer;}
    .select_result .triangle{border:5px solid transparent;border-top:5px solid #666;position: absolute;top: 16px; right:8px;}
    .select_item   ul{display:none;position:absolute;top:100%;right:0;width:100px;background:  #f3f3f3;border:1px solid #ccc;border-radius:0 0 4px 4px;  border-top-color:#f3f3f3;margin-top:-4px;}
    .select_item ul li{text-align: center;cursor: pointer;}
    .select_item ul li:hover{background: #f4a100; color: #fff;} 
  <scriptsrc=>=> 
<script>
function select(){
$(document).click(function(){
$(".select_module_con ul").slideUp();
})
var module=$(".select_result");
module.click(function(e){
e.stopPropagation();
var ul=$(this).next();
ul.stop().slideToggle();
ul.children().click(function(e){
e.stopPropagation();
$(this).parent().prev().children("span").text($(this).text());
ul.stop().slideUp();
})
})
}
$(function(){
select();
})
</script>
  ="select_contain">
      =>
        =>
   
        =>
          ="select_result">
            选择节目
            ="triangle">

이 기사의 사례를 읽으신 후 방법을 마스터하셨다고 생각합니다. 더 흥미로운 정보를 보려면 PHP 중국어 웹사이트의 다른 관련 기사를 주목하세요!

추천 자료:

Angular2 개발 구성 요소 단계별 설명

Ajax에서 사용자 세션 오류 처리

http 하이재킹된 플로팅 광고 처리 방법

위 내용은 JS를 사용하여 드롭다운 상자 기능 구현의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.