html
<button type="button" id="btn_create">생성</button> <input type="text" id="guid" value="" />css
#guid { width:500px; }javascript
var _guid = {}; _guid.get = function() { return _guid.s4() + _guid.s4() + _guid.s4() + _guid.s4() + _guid.s4() + _guid.s4() + _guid.s4() + _guid.s4(); } _guid.s4 = function() { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); } $('#btn_create').on('click', function(){ $('#guid').val(_guid.get()); });
demo : jsfiddle link
'js > jQuery' 카테고리의 다른 글
[javascript] 모달 사용시 콜백 예제 (0) | 2018.01.25 |
---|---|
[jquery] div 스크롤 감지(바닥, 끝) (0) | 2018.01.24 |
[jquery mobile] ListView scroll load more (0) | 2017.07.03 |
[jquery mobile] swipe event (0) | 2017.07.03 |
[jQuery] to find checkbox and change attribute (0) | 2017.06.26 |