'자동차' 카테고리의 다른 글
현대 제네시스 G70 발표 (0) | 2017.09.15 |
---|---|
[Ford] 포드 F150 (0) | 2017.04.18 |
[Benz] 벤츠 C63 AMG 쿠페 (0) | 2017.04.18 |
[BMW] BMW I8 (0) | 2017.04.18 |
현대 제네시스 G70 발표 (0) | 2017.09.15 |
---|---|
[Ford] 포드 F150 (0) | 2017.04.18 |
[Benz] 벤츠 C63 AMG 쿠페 (0) | 2017.04.18 |
[BMW] BMW I8 (0) | 2017.04.18 |
Foreach와 같은 jQuery
$.each(array,function(index, item){
var output='';
output+='<a href="'+item.link+'">';
output+='<h1>'+item.name+'</h1>';
output+='</a><br>';
document.body.innerHTML+=output;
})
forEach응용방법
array.forEach(function (item){
//console.log(item.name+' / '+item.link);
var output='';
output+='<a href="'+item.link+'">';
output+=item.name;
output+='</a><br>';
document.body.innerHTML+=output;
});
배열과 For문, 향상된 FOR문
<script type="text/javascript" src="./js/jquery-2.1.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var array=[
{name:'Naver',link:'http://www.naver.com'},
{name:'Daum',link:'http://www.daum.net'},
{name:'google',link:'http://www.google.com'}
];
//for
for(var i=0;i<array.length;i++){
console.log(array[i].name+'/'+array[i].link);
}
for(var i in array){
console.log(array[i].name+'/'+array[i].link);
}
});
</script>
배열관리 .each
<script type="text/javascript" src="./js/jquery-2.1.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('h2').each(function(index,item){
//console.log(index);
//console.log(item);
//console.log(item.innerHTML);
this.innerHTML='hello';
})
});
</script>
<body>
<h2>item-0</h2>
<h2>item-1</h2>
<h2>item-2</h2>
<h2>item-3</h2>
</body>
객체의 확장
<script type="text/javascript" src="./js/jquery-2.1.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var object={name:'윤인성'};
$.extend(object,{
region:'서울특별시 강서구',
part:'세컨드 기타'
})
var output='';
$.each(object, function(key,item){
output+=key+' : '+item+'\n';
})
alert(output);
});
</script>
[출처] http://blog.naver.com/skawo32167/220493716793
jquery css 적용 방법 (0) | 2017.07.26 |
---|---|
[Jquery radio button] 제이쿼리 라디오버튼 제어 (1) | 2017.05.18 |
jquery 숫자만 입력받기 (0) | 2017.04.17 |
Jquery Number 숫자 유효성 체크 (0) | 2017.04.05 |
jquery checkbox 체크여부/제어하기/체크갯수 구하기 (0) | 2017.03.17 |
1 2 3 4 5 6 7 8 9 10 11 | /* ** 폼 ** ** <input type="text" numberonly="true" /> // 숫자만 입력 가능한 텍스트박스 ** <input type="text" datetimeonly="true" /> // 숫자, 콜론(:), 하이픈(-)만 입력 가능한 텍스트박스 */ $( function () { $(document).on( "keyup" , "input:text[numberOnly]" , function () {$( this ).val( $( this ).val().replace(/[^0-9]/gi, "" ) );}); $(document).on( "keyup" , "input:text[datetimeOnly]" , function () {$( this ).val( $( this ).val().replace(/[^0-9:\-]/gi, "" ) );}); }); |
만약 on 메소드가 없는 존나 옛날 버전이라면
1 2 3 4 5 6 7 8 9 | $( function () { $( "input:text[numberOnly]" ).live( "keyup" , function () { $( this ).val( $( this ).val().replace(/[^0-9]/gi, "" ) ); }); $( "input:text[datetimeOnly]" ).live( "keyup" , function (){ $( this ).val( $( this ).val().replace(/[^0-9:\-]/gi, "" ) ); }); }); |
으로 해주면 된다.
약간에 문제가 있는듯 합니다.
한글만 입력하고 focus가 나가면 한글 1글자가 남는.....
출처: http://hobbiez.tistory.com/396 [취미생활]
[Jquery radio button] 제이쿼리 라디오버튼 제어 (1) | 2017.05.18 |
---|---|
jquery 배열, for문, 향상된 for문 each 객체의 확장 (0) | 2017.04.18 |
Jquery Number 숫자 유효성 체크 (0) | 2017.04.05 |
jquery checkbox 체크여부/제어하기/체크갯수 구하기 (0) | 2017.03.17 |
jQuery 좌표구하기 (0) | 2017.03.17 |