JQuery Select Box 디자인
[code]
<style type="text/css">
.SearchWrap { display:inline-block; vertical-align:top; width:96px; }
.SearchJQuery { border:1px solid #d4d4d4; height:30px; position:relative; cursor:pointer; }
.SearchJQuery span { position:absolute; top:10px; right:14px; color:#e60012; }
.SearchJQuery div { position:absolute; top:10px; left:7px; color:#2a2a2a; font-weight:bold; }
.SearchJQuery ul { position:absolute; border:1px solid #d4d4d4; border-bottom:0; width:100%; top:30px; left:-1px; background-color:#FFF; margin:0; padding:0; display:none; }
.SearchJQuery ul li { list-style-type:none; height:24px; line-height:26px; padding:0 0 0 7px; cursor:pointer; color:#999; border-bottom:1px solid #d4d4d4; }
.SearchJQuery ul li:hover { background-color:#ddd; color:#000; }
</style>
<span class="SearchWrap">
<div class="SearchJQuery">
<span>▼</span>
<div></div>
<input type="hidden" value=""/>
<ul>
<li title="">전체</li>
<li title="sell">상품명</li>
<li title="home">상점명</li>
</ul>
</div>
</span>
<script type="text/javascript">
$(".SearchJQuery").click(function(){
$(this).children('ul').toggle(100);
});
$(".SearchJQuery").each(function(){
if($(this).children('input').val()){
$(this).children('div').text($(this).children('ul').children("li[title='"+$(this).children('input').val()+"']").text());
}else{
var NotTitle = $(this).children('ul').children("li[title='"+$(this).children('input').val()+"']").text();
if(NotTitle){
$(this).children('div').text(NotTitle);
}else{
$(this).children('div').text($(this).children('ul').children('li:first').html());
$(this).children('input').val($(this).children('ul').children('li:first').attr('title'));
}
}
});
$(".SearchJQuery > ul > li").click(function(){
$(this).parents('div').children('div').text($(this).text());
$(this).parents('div').children('input').val($(this).attr('title'));
});
</script>
[/code]
개코딩 이해 바랍니다....
필요해서 만들었는데 팁으로 올려놓으면 쓰신분들이 있으실거 같아서! 올려봅니다. ㅎ
<style type="text/css">
.SearchWrap { display:inline-block; vertical-align:top; width:96px; }
.SearchJQuery { border:1px solid #d4d4d4; height:30px; position:relative; cursor:pointer; }
.SearchJQuery span { position:absolute; top:10px; right:14px; color:#e60012; }
.SearchJQuery div { position:absolute; top:10px; left:7px; color:#2a2a2a; font-weight:bold; }
.SearchJQuery ul { position:absolute; border:1px solid #d4d4d4; border-bottom:0; width:100%; top:30px; left:-1px; background-color:#FFF; margin:0; padding:0; display:none; }
.SearchJQuery ul li { list-style-type:none; height:24px; line-height:26px; padding:0 0 0 7px; cursor:pointer; color:#999; border-bottom:1px solid #d4d4d4; }
.SearchJQuery ul li:hover { background-color:#ddd; color:#000; }
</style>
<span class="SearchWrap">
<div class="SearchJQuery">
<span>▼</span>
<div></div>
<input type="hidden" value=""/>
<ul>
<li title="">전체</li>
<li title="sell">상품명</li>
<li title="home">상점명</li>
</ul>
</div>
</span>
<script type="text/javascript">
$(".SearchJQuery").click(function(){
$(this).children('ul').toggle(100);
});
$(".SearchJQuery").each(function(){
if($(this).children('input').val()){
$(this).children('div').text($(this).children('ul').children("li[title='"+$(this).children('input').val()+"']").text());
}else{
var NotTitle = $(this).children('ul').children("li[title='"+$(this).children('input').val()+"']").text();
if(NotTitle){
$(this).children('div').text(NotTitle);
}else{
$(this).children('div').text($(this).children('ul').children('li:first').html());
$(this).children('input').val($(this).children('ul').children('li:first').attr('title'));
}
}
});
$(".SearchJQuery > ul > li").click(function(){
$(this).parents('div').children('div').text($(this).text());
$(this).parents('div').children('input').val($(this).attr('title'));
});
</script>
[/code]
개코딩 이해 바랍니다....
필요해서 만들었는데 팁으로 올려놓으면 쓰신분들이 있으실거 같아서! 올려봅니다. ㅎ
댓글 2개
뜨거운형제들
10년 전
<li title="">전체</li> 을 없애 버리시면 자동으로 li에 있는 첫번째가 자동으로 잡힙니다.
또한 <input type="hidden" value=""/> 에 value에 value데이터를 넣으면 자동으로 선택되고..
아..설명하기 어렵네요..
일반 select option 기능과 흡사하게 만들었습니다. ㅎ
또한 <input type="hidden" value=""/> 에 value에 value데이터를 넣으면 자동으로 선택되고..
아..설명하기 어렵네요..
일반 select option 기능과 흡사하게 만들었습니다. ㅎ
뜨거운형제들
10년 전
$(this).parents('.SearchJQuery').children('div').text($(this).text());
$(this).parents('.SearchJQuery').children('input').val($(this).attr('title'));
으로 수정해주세요...
$(this).parents('.SearchJQuery').children('input').val($(this).attr('title'));
으로 수정해주세요...
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4417 | ||
| 474 | 10년 전 | 6584 | ||
| 473 | 10년 전 | 5047 | ||
| 472 | 10년 전 | 5584 | ||
| 471 | 10년 전 | 8274 | ||
| 470 | 10년 전 | 6896 | ||
| 469 |
|
10년 전 | 6058 | |
| 468 |
|
10년 전 | 7997 | |
| 467 | 10년 전 | 8730 | ||
| 466 |
|
10년 전 | 7380 | |
| 465 |
carlpark
|
10년 전 | 9953 | |
| 464 | 10년 전 | 5084 | ||
| 463 |
잘살아보자
|
10년 전 | 12313 | |
| 462 | 10년 전 | 10805 | ||
| 461 | 10년 전 | 6375 | ||
| 460 |
|
10년 전 | 8708 | |
| 459 | 10년 전 | 5758 | ||
| 458 |
잘살아보자
|
10년 전 | 5568 | |
| 457 |
잘살아보자
|
10년 전 | 9317 | |
| 456 | 10년 전 | 8061 | ||
| 455 | 10년 전 | 9035 | ||
| 454 | 10년 전 | 9754 | ||
| 453 | 10년 전 | 11444 | ||
| 452 | 10년 전 | 7434 | ||
| 451 | 10년 전 | 54864 | ||
| 450 | 10년 전 | 4972 | ||
| 449 | 10년 전 | 9986 | ||
| 448 | 10년 전 | 9500 | ||
| 447 | 10년 전 | 9116 | ||
| 446 | 10년 전 | 7113 | ||
| 445 | 10년 전 | 17320 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기