select 선택에 따라 테두리 색상 변경
<style>
.ex-select {padding:0.5em; border-radius:0.5em; border:1px solid;}
</style>
<select class="ex-select">
<option value="red" data-color="red">red</option>
<option value="green" data-color="green">green</option>
<option value="blue" data-color="blue">blue</option>
<option value="tomato" data-color="tomato">tomato</option>
<option value="lightblue" data-color="lightblue">lightblue</option>
</select>
<script>
$(function() {
$('.ex-select').change(function(e) {
var $this = $(this);
var c = $this.find('option:selected').data('color');
$this.css({'color':c, 'border-color': c});
});
$('.ex-select').each(function() {
var $this = $(this);
$this.trigger('change');
$this.find('option').each(function() {
$(this).css('color',$(this).data('color'));
});
});
});
</script>
댓글 3개
게시글 목록
| 번호 | 제목 |
|---|---|
| 15819 |
jQuery
제이쿼리 jQuery( ":button" )
|
| 15818 | |
| 15817 | |
| 15816 | |
| 15815 | |
| 15814 | |
| 15813 | |
| 15812 | |
| 15811 | |
| 15810 | |
| 15809 |
jQuery
제이쿼리 .attr (attributeName)
|
| 15808 |
jQuery
제이쿼리 .appendTo( target )
|
| 15807 | |
| 15806 |
jQuery
animated selector
|
| 15805 | |
| 15804 |
jQuery
제이쿼리 andSelf()
|
| 15803 |
jQuery
제이쿼리 all selector
|
| 15802 |
jQuery
제이쿼리 .ajaxSuccess(handler)
|
| 15801 |
jQuery
.ajaxStop(handler )
|
| 15800 |
jQuery
.ajaxStart(handler )
|
| 15799 |
jQuery
.ajaxSend (handler )
|
| 15798 |
jQuery
제이쿼리 .ajaxError (handler)
|
| 15797 |
jQuery
제이쿼리 .ajaxComplete (handler)
|
| 15796 |
jQuery
제이쿼리 .after()
|
| 15792 | |
| 15791 |
jQuery
제이쿼리 .addBack ()
|
| 15790 |
jQuery
제이쿼리 .add (selector)
|
| 15789 | |
| 15788 | |
| 15787 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기