Frage

I have this problem with prototype.js when I include $(document).ready in my webpage it doesn't work.

Here is part of my code:

<script type="text/javascript" src="<?php echo base_url();?>asset/scripts/prototype.js"></script>
<script type="text/javascript">    
  function nl2br (str, is_xhtml) {   
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';    
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
  }

  $(document).ready(function(){
    $('#sendmail2').on('submit', function(){
      alert('Ok');
    });
  });           
</script>

But when I remove prototype the script works fine.

War es hilfreich?

Lösung

change all "$" with extended name "jQuery"

jQuery(document).ready(function(){

Andere Tipps

Try using

jQuery(document).ready

instead of

$(document).ready
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top