테스트 사이트 - 개발 중인 베타 버전입니다

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

토실아빠 5년 전 조회 2,331

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

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

 

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

         89                                         89 건

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

이런 모양입니다.

 

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

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

 

</p>

<p> </p>

<p><?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'];</p>

<p>$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></p>

<p> </p>

<p>

 

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트

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

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

토실아빠
5년 전
제로나라님 감사합니다. 한방에 해결되네요~

댓글을 작성하려면 로그인이 필요합니다.

하재하재

p태그는 block입니다.

span을 쓰셔야 합니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

토실아빠
5년 전
웨일즈스튜디오님 감사합니다.
제가 너무 몰라 답답하셨을 텐데. 이번에 웨일즈스튜디오님 덕분에 자세하게 알았습니다.

댓글을 작성하려면 로그인이 필요합니다.

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

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

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

토실아빠
5년 전
쟁방짜장님 감사합니다. 저번에도 많은 도움이 되었습니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인