donkey111111 2012-04-23 01:55
浏览 29
已采纳

jQuery函数仅在再次包含时才起作用 - 两次(导致其他冲突)

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?

  • 写回答

3条回答 默认 最新

  • duankezong4064 2012-08-18 03:06
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致