2

当我使用 jquery 灯箱(运行原型)和 jquery 新闻滑块时,我一直遇到问题。

我尝试了“无冲突”方法。

问题是我不知道放置代码的确切位置。

所以,在这里,我将我的脚本放在 .

所以,请解决它并解释我在哪里放置补丁。

非常感谢您。

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Jquery</title> 

<script type="text/javascript" src="lb/js/prototype.js"></script>
<script type="text/javascript" src="lb/js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="lb/js/lightbox.js"></script>
<link href="lb/css/lightbox.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="news/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="news/jquery.easynews.js"></script>



<style>
html
{ background-color: #FFA928;
font: normal 76% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
 color:black;
 }
a { text-decoration: none; font-weight: bold; }

.news_style{
display:none;
}
.news_show
{
background-color: white;
color:black;
width:350px;
height:150px;
font: normal 100% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
overflow: auto; 

}
.news_border
{
background-color: white;
width:350px;
height:150px;
font: normal 100% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 1px solid gray;
padding: 5px 5px 5px 5px;
overflow: auto; 

}
.news_mark{
background-color:white ;
font: normal 70% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 0px solid gray;
width:361px;
height:35px;
color:black;
text-align:center;
}
.news_title{
font: bold 120% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 0px solid gray;
padding: 5px 0px 9px 5px;
color:black;
}
.news_show img{

margin-left: 5px;
margin-right: 5px;

}
.buttondiv
{
position: absolute;
/*float: left;*/
/*top: 169px;*/
padding: 5px 5px 5px 5px;
background-color:white ;
border: 1px solid gray;
/*border-top-color: white;*/
border-top:none;
height:20px;
}

</style>
<script>
$(document).ready(function(){
var newsoption1 = {
  firstname: "mynews",
  secondname: "showhere",
  thirdname:"news_display",
  fourthname:"news_button",
   newsspeed:'6000'
}
$.init_news(newsoption1);


var myoffset=$('#news_button').offset();

var mytop=myoffset.top-1;

$('#news_button').css({top:mytop});

});
</script>

</head>
4

3 回答 3

3

我不知道你能比这里的解释清楚多少

从本质上讲,调用会将变量jQuery.noConflict释放$为在加载 jQuery 之前定义的任何变量。

之后你需要调用 jQuery 来直接使用它。就我而言,我像这样重新定义它:

$j = jQuery; // Now I can use $j for jQuery and $ for Prototype

您还可以在准备好的函数中使用 $ ,如下所示:

jQuery(document).ready(function($) {
  // Code that uses jQuery's $ can follow here.
});

很简单……你在困惑什么?

于 2010-04-03T05:11:52.743 回答
0

诶?jQuery 灯箱不使用原型。你到底在用什么?

试试这个http://leandrovieira.com/projects/jquery/lightbox/

如果可以的话,把原型全部转储在一起。最好避免使用两个笨重的框架。

于 2010-04-03T05:10:33.867 回答
0

在包含 jquery 库后立即进行 $.noConflict() 调用。见这里

<script type="text/javascript" src="news/jquery-1.2.3.pack.js"></script>
<script type="text/javascript">
  $.noConflict();
  // Code that uses other library's $ can follow here.
</script>
于 2010-04-03T05:15:40.950 回答