Question

I'm using this jQuery script / function to change the design of my select box: http://tutorialzine.com/2010/11/better-select-jquery-css3/

It's implemented and working. My site is built up by an index file that includes all other parts of the page via php include: parts like about, contact, etc.

The problem though is that in the separate contact page (not including a header, only body content) where my styled select boxes are displayed, the "styling" if you will only works when jquery is included once again directly in the contact.php file (already included in index.php).

  <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>

Once removed from contact.php, all select option items are set to null. This wouldn't be much of a problem if only datePicker in another part of the site didn't stop working as what I believe to be a consequence of including jQuery twice.

I've tried all sorts of solutions like checking if it's really there:

 if (typeof jQuery == 'undefined') {  
 document.write('<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>');
 }

jQuery is not undefined, it's there all right, you can even see it when browsing through the source code. Any ideas on why this is happening?

Était-ce utile?

La solution

I solved my issue a few days after i posted this. The problem was that jQuery was included three times altogether (because of php include). This caused my initial problem. When I removed what I believed to be the second and unneccesary jquery, there was still one too many. So please consider this while dealing with similar errors, you might have included it far more times than you realize and one solution would be to really make sure only one jquery include is running. Good luck

Autres conseils

use jquery from google not your own server some times our jquery library dosen't work properly...

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>

Are you running your code inside

$(function() {
    // Your jQuery code here
});

jQuery needs to be initiated, which happends on page load. Perhaps you're trying to do some functions that are executed before jQuery is ready?

EDIT:
Noticed this suggestion to be mentioned in comments.

You're not using <iframe> for contact.php, are you?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top