初学JQuery,说实话还真不适应;
看了这哥们的博客http://thinhunan.cnblogs.com/archive/2008/03/05/1091816.html
正在学习中。
文中提到了用JQuery来改变css:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery basic</title>
<style type="text/css">
.selected
{
background-color:Yellow;
}
</style>
<script src="jquery-1.10.2.js" type="text/javascript"></script>
</head>
<body>
<h3>jQuery构造函数</h3>
<ul id="_ul">
<li>jQuery(expression,context)</li>
<li>jQuery(html)</li>
<li>jQuery(elements)</li>
<li>jQuery(fn)</li>
</ul>
<script type="text/javascript">
var oUI=document.getElementById('_ul');
var oLi=document.createElement('li');
oLi.innerHTML='new';
oUI.style.color ='red';
/*
jQuery("ul>li:first").addClass("selected");
$('ul').append($('<li>new item</li>'));
$(document).ready(function(){
$('ul').css('color','#f345f3');});
*/
oUI.appendChild(oLi);
</script>
</body>
</html>
用oUI.style.color='red';这句可以改变样式颜色,但是用setAttribute函数就不好使了。
但是用jQuery貌似能方便些,但是么有什么感觉,先看看吧。