JQuery 學習筆記(一)

初學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貌似能方便些,但是麼有什麼感覺,先看看吧。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章