728x90
반응형
<input type='text' name="percentage"/>
<script type="text/javascript">
$(document).ready(function(){
$("input[name='percentage']").on('input', function() {
$(this).val(function(i, v) {
return v.replace('%','') + '%'; });
});
});
</script>
$()안에 input태그 안의 id값으로 설정해줘도 되고, class 값으로 설정해줘도 된다.
$("input[name='percentage']") 대신에
$('#id값')
$('.class값')
출처 : https://codepen.io/mesapkota/pen/bMoqZR
Adding percentage to input box using jquery
...
codepen.io
728x90
반응형
'Front > JS & jQuery' 카테고리의 다른 글
[echarts] 데이터를 차트 안에 표시하기 (0) | 2022.05.14 |
---|---|
[jQuery] .ready() 와 .onload() 의 차이 (0) | 2022.05.13 |
[jQuery] 동적으로 selectbox만들기 , selected 속성 추가하기 (0) | 2022.05.11 |
[echarts] 차트 여러 개 그리기 (0) | 2022.05.09 |
[datatables] columns.data.render (0) | 2022.05.08 |