Spent 2 days trying to figure this out: in the code below the true condition for the "if" will cause ALL <div class="commentcount"> to read "castor" ... if the condition is false it will read "pollux" on ALL <div class="commentcount">.
I have solved this issue before by using the $(this) provided by jQuery unfortunately this time I can't figure out how to get it in there without breaking the if / else from actually making the replacement.
Please note that I have constructed this example to be simple, this is not production code...Does ANYONE know how to get this working?
I have solved this issue before by using the $(this) provided by jQuery unfortunately this time I can't figure out how to get it in there without breaking the if / else from actually making the replacement.
Please note that I have constructed this example to be simple, this is not production code...Does ANYONE know how to get this working?
Code:
<script>
//<![CDATA[
var postID = <?php the_id() ?>;
if (postID > 0) {
$(".commentcount").html('castor');
}
else {
$(".commentcount").html('pollux');
}
//]]>
</script>