jsp中怎么应用jquirey
1个回答
展开全部
首先要导入jQuery的包文件,提前下载。
然后在JSP中引入包:
[javascript] view plaincopy
<mce:script src="lib/jquery-1.5.2.js" mce_src="lib/jquery-1.5.2.js" type="text/javascript"></mce:script>
接下来再引入自己的js:
[javascript] view plaincopy
<mce:script src="my.js" mce_src="my.js" type="text/javascript"></mce:script>
我的my.js文件内容如下:
[javascript] view plaincopy
$(document).ready(function() {
$("<div><p>Hello</p></div>").appendTo("body");
$("#stop").css("background","yellow");
$("li").toggle(
function () {
$(this).css({"list-style-type":"disc", "color":"blue"});
},
function () {
$(this).css({"list-style-type":"disc", "color":"red"});
},
function () {
$(this).css({"list-style-type":"disc", "color":"gray"});
}
);
});
然后在JSP中引入包:
[javascript] view plaincopy
<mce:script src="lib/jquery-1.5.2.js" mce_src="lib/jquery-1.5.2.js" type="text/javascript"></mce:script>
接下来再引入自己的js:
[javascript] view plaincopy
<mce:script src="my.js" mce_src="my.js" type="text/javascript"></mce:script>
我的my.js文件内容如下:
[javascript] view plaincopy
$(document).ready(function() {
$("<div><p>Hello</p></div>").appendTo("body");
$("#stop").css("background","yellow");
$("li").toggle(
function () {
$(this).css({"list-style-type":"disc", "color":"blue"});
},
function () {
$(this).css({"list-style-type":"disc", "color":"red"});
},
function () {
$(this).css({"list-style-type":"disc", "color":"gray"});
}
);
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询