http://code.ovidiu.ch/

http://code.ovidiu.ch/dragdealer/

Dragdealer JS

Drag provider – the good stuff

Dragdealer is a drag-based JavaScript component that embraces endless front-end solutions. Elegantly crafted for JavaScript-aware coders.

2D drag and tap, mouse and touch (mobile tested), 12kB unminified. No dependency.

Take a look through all the demos below to understand how it works.


크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/11/01 17:52 2010/11/01 17:52
, , , , ,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5604

jQuery 에서 Select input 에 option 을 추가 삭제하는 코드이다. 영어라 두려워말고 살짝 읽어보면 이해 가능할 것이다.

URL : http://www.electrictoolbox.com/jquery-add-option-select-jquery/


select box의 내용 가져오기
    $("#select_box > option:selected").val();
select box의 값 설정
    $("#select_box > option[@value=지정값]").attr("selected", "true")

My last jQuery post looked at how to count the number of options in a select and then clear all options from the select. This post looks at how to add a new option to a select with jQuery.

Working Example

The following is an example showing an already populated select. Clicking the "Add option" button adds a new option to the end of the select and makes it the selected one. Clicking "Replace options" replaces them with a new set of options and then selects the "Green" one.

Note that the above example will not work if you are reading this in a feed reader. In this case click through to view this post in a web browser.

Adding a single option - by appending HTML

Adding a single option can be done by appending HTML to the select box. The select in the above example has an id of "example" i.e. <select id="example"> and using this method adding a new option by appending HTML can look like this:

1$('#example').append('<option value="foo" selected="selected">Foo</option>');

This newly added option will be the selected option; to change this behavior remove the selected="selected" part.

Adding a single option - by appending a new option - method 1

To avoid having to write and append HTML and stick with a more Javascript approach the new option can be appended with jQuery by creating a new option object. This next example does not work correctly in Internet Explorer; it will add the new option but only the value and not display any text.

1$('#example').append(new Option('Foo', 'foo', true, true));

The true, true part at the end will make this item the selected one.

Adding a single option - by appending a new option - method 2

This method gets a handle to the options and adds a new option to the array of options. This does work in Internet Explorer and is the more traditional Javascript way of adding options.

1var options = $('#example').attr('options');
2options[options.length] = new Option('Foo', 'foo', true, true);

Adding multiple options

Using the final method above this last example shows how to replace the existing set of options with a new set, which may have been retrieved from an AJAX call or similar.

01var newOptions = {
02    'red' : 'Red',
03    'blue' : 'Blue',
04    'green' : 'Green',
05    'yellow' : 'Yellow'
06};
07var selectedOption = 'green';
08 
09var select = $('#example');
10var options = select.attr('options');
11$('option', select).remove();
12 
13$.each(newOptions, function(val, text) {
14    options[options.length] = new Option(text, val);
15});
16select.val(selectedOption);

Lines 1 to 7 define the new options with an associative array and the one which will be selected. This is what might have been retrieved from an AJAX call.

Lines 9 and 10 cache a handles to #example and its options.

Line 11 removes all the existing options.

Lines 13 to 15 loop through the new options and add them to the select box.

And finally line 16 sets the selected option.

Alternative methods

There are some alternative methods to adding options to a select box with jQuery using various plug-ins and I may look at these in a future post.

Related posts:


크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/11/01 09:49 2010/11/01 09:49
, , ,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5603

2010.11.01 수영 강습

간만에 수영강습. 은평구청소년수련관에 11월 새벽 6시 수영강습(월~토)등록.
오늘 처음이었는데 후덜덜하다.
5시 기상해서, 슈슈님모시고 6시까지 도착.
샤워하고 오리발 안하는 라인가서 아무렇지도 않은듯 준비체조를~
월,목 오리발이란다. 마레스 클리퍼 하나 주문해야겠구만.
일단 중급반에서 하기로 했다.

킥판잡고 자유형&평형발차기 4바퀴
자유형 4바퀴
땅콩키고 자유형&평형 스트로크 3바퀴
평형스트로크 접영발차기 2바퀴
자유형 3바퀴
접영 25m 3회

중간에 활배근에 경련이 일어나서 팔이 돌아가지 않아서 완전 애먹었다.
과연 일주일에 얼마나 나갈 수 있을 것인가?
간만에 강습. 기분은 좋다~ ㅎㅎㅎ

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/11/01 09:16 2010/11/01 09:16
Keyword 수영,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5602

모든 일을 낙관하라

모든 일을 낙관하라
어떤 일을 시작하면 일단 잘 될 것이라고 낙관하라.
그러면 그 낙관론이 성공을 안겨줄 것이다.
일시적으로 삐걱거리더라도 더 잘 되기 위한 진통으로 받아들이고
더 잘 될 결과를 생각하라.
- 톰 피터스, ‘리틀 빅씽’에서

약 30년을 실리콘밸리에서 살아온 톰 피터스는
‘어떻게 보면 무모해 보이기까지 한 애플과 인텔의 낙관주의가
그들을 초우량 기업으로 성장시키는 것을 지켜보았다’고 말합니다.
그렇습니다.
혁신을 이끌어내는 진정한 힘은 낙관에서 나옵니다.
비관이 아닌 낙관이 세상을 변화시킵니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/11/01 08:52 2010/11/01 08:52
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5601

내면의 아름다움

아름다움은
내면에서 절로 나옵니다.
겉치장에서 아름다움을 찾는 사람은
금방 겉치레가 들통이 나지요. 진정한 자신의 모습을
자연스럽게 내보이면 모두가 알아봅니다.
자연스러운 아름다움을 가꾸어갈
때입니다. 소박하게.


- 이우성의《정말 소중한 것은 한 뼘 곁에 있다》중에서 -


* 때로는 겉치장도 필요합니다.
잘 가꾸고 다듬어 아름답게 관리해야 합니다.
그러나 동시에 자기의 내면도 잘 가꾸어야 합니다.
진정한 아름다움은 겉모습에서 나오는 것이 아니니까요.
내면에서 아름다움이 내뿜어 나오면
겉모습은 그다지 문제가
되지 않습니다. 

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/11/01 08:51 2010/11/01 08:51
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5600


블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2010/11   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
Statistics Graph

Site Stats

Total hits:
181301
Today:
180
Yesterday:
209