select 선택에 따라 테두리 색상 변경
페이지 정보
작성자 최고관리자 댓글 0건 조회 2,604회 작성일 18-11-26 13:26본문
<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>
댓글목록
등록된 댓글이 없습니다.