1

So i have a div that contains the text "12:00PM" .. it's a little clock application.

<div id="#clock">12:00PM</div>

I wanted to make the ":" part disappear and then reappear..

I wonder if this was possible w/ jQuery.

i have all the intervals and everything worked out... my clock gets updated.. but i just need a way to target/select that ":" character.. and remove it.. and then replace it :)

Is this possible without being too complicated?

Thanks

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
BrownChiLD
  • 3,545
  • 9
  • 43
  • 61

3 Answers3

2

Html:

<div id="#clock">12<span id="clock-colon">:</span>00PM</div>

jQuery:

$('#clock-colon').hide() // do what you want
Phil
  • 10,948
  • 17
  • 69
  • 101
2

DEMO

HTML is unchanged

CSS

.hidden {
    visibility:hidden;
}

jQuery

$clock = $("#clock");
$blink = true;
setInterval(function(){
    if ($blink) {
        $clock.html($clock.html().replace(":",'<span class="hidden">:</span>'));
        $blink = false;
    }
    else {
        $clock.html($clock.html().replace('<span class="hidden">:</span>',":"));
        $blink = true;
    }
}, 1000);
kei
  • 20,157
  • 2
  • 35
  • 62
1

If it's always going to be the same character, use the search() or indexOf() methods and then substring() and concatenation to eliminate the character.