0

I have the following bit of code that works with jQuery, which is causing a jQuery conflict that I simply can not resolve, because of the limitations of the ystsem I am working with.

<script type="text/javascript">
$(document).ready(function() {
    if (<?php echo $totalpage?> > 14) {
        $('#fpointer').show();
    }
});
</script>;

So my questions is can I convert this code to JavaScript which can run without jQuery? I think I can figure out most of it but the part I'm not sure about is the $(document).ready(function() and how that translates.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Naz
  • 900
  • 2
  • 10
  • 25

2 Answers2

2

I think you can do this with simple JavaScript:

document.addEventListener("DOMContentLoaded", function(event) { 
    document.getElementById('fpointer').style.display = 'block';
});
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
stackrocha
  • 405
  • 2
  • 8
1

Before you read ahead, checkout about jQuery.noConflict().

Replacing jQuery with Javascript:

Remove $(document).ready(function()

and replace $('#fpointer').show(); with:

document.getElementById("fpointer").style.display = "inline";

So, your code should look like:

<script type="text/javascript">
    if (<?php echo $totalpage?> > 14) {
       document.getElementById("fpointer").style.display = "inline";
    }
</script>
Rahul Desai
  • 15,242
  • 19
  • 83
  • 138