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.

Elrond_EGLDer
  • 47,430
  • 25
  • 189
  • 180
Naz
  • 832
  • 2
  • 8
  • 23

2 Answers2

2

I think you can do this with simple JavaScript:

document.addEventListener("DOMContentLoaded", function(event) { 
    document.getElementById('fpointer').style.display = 'block';
});
Elrond_EGLDer
  • 47,430
  • 25
  • 189
  • 180
rennyrocha
  • 415
  • 2
  • 7
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
  • 13,802
  • 14
  • 75
  • 128