카운팅 출력물 뒤에 바로 글씨가 출력되도록 하고 싶어요.

카운팅 출력물 뒤에 바로 글씨가 출력되도록 하고 싶어요.

QA

카운팅 출력물 뒤에 바로 글씨가 출력되도록 하고 싶어요.

본문

이전에 열공님의 도움으로 만든게시글 카운팅이 되는 코드 입니다.

다름이 아니라 수치가 출력되는 <td><p id="counter2"></p></td> 부분에서 뒤에 "건" 을 붙이고 싶은데 <td><p id="counter2"></p>건</td> 이렇게 하면 한칸 내려진 상태로 "건"이 출력됩니다.

 

현재 출력상태                           원하는 출력상태

         89                                         89 건

         건                                이런모양으로 출력하고 싶습니다.

이런 모양입니다.

 

어떻게 하면 저 수치 뒤에 바로 "건"이란 글씨가 나오게 할 수 있을까요.?

도움 부탁드립니다. 감사합니다.

 


 
<?php
$list_b = sql_fetch("select count(*) as bo_count_write from g5_write_sub_com_search where wr_is_comment=0 ");
$list_b = $list_b['bo_count_write'];
$list_a = sql_fetch("select count(*) as bo_count_write from g5_write_order where wr_is_comment=0 ");
$list_a = $list_a['bo_count_write'];
 
$comment_a = sql_fetch("select count(*) as bo_count_comment from g5_write_order where wr_is_comment=1 ");
$comment_a = $comment_a['bo_count_comment'];
 
?>
<script>
function numberCounter(target_frame, target_number) {
    this.count = 0; this.diff = 0;
    this.target_count = parseInt(target_number);
    this.target_frame = document.getElementById(target_frame);
    this.timer = null;
    this.counter();
};
    numberCounter.prototype.counter = function() {
        var self = this;
        this.diff = this.target_count - this.count;
   
        if(this.diff > 0) {
            self.count += Math.ceil(this.diff / 5);
        }
   
        this.target_frame.innerHTML = this.count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
   
        if(this.count < this.target_count) {
            this.timer = setTimeout(function() { self.counter(); }, 45);
        } else {
            clearTimeout(this.timer);
        }
    };
window.onload = function(){
new numberCounter("counter3", <?php echo $list_b; ?>);
new numberCounter("counter2", <?php echo $list_a; ?>);
new numberCounter("counter1", <?php echo $comment_a; ?>);
}
</script>
<table  class="mainBasicCont02">
<h2>
<tr>
<th><font size="4">counter1</font></th><th><font size="4">counter2</font></th><th><font size="4">counter3</font></th>
</tr>
<tr>
<td><p id="counter2"></p></td><td><p id="counter1"></p></td><td><p id="counter3"></p></td>
</tr>
</h2>
</table>
</h2>
 

 

이 질문에 댓글 쓰기 :

답변 3

<p> 를 <span> 으로 교체해 보세요.

this.target_frame.innerHTML = this.count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + "건";

이렇게 직접 붙이셔도 되지 않을까요?

p태그는 block입니다.

span을 쓰셔야 합니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 123,604 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT