關於jquery的css的一些知識

來源:互聯網
上載者:User

標籤:null   開發   知識   開發人員   應用程式   互動   cookie   cursor   應用   

Query執行個體CSS 樣式表動態選擇
本執行個體主要說的還是jquery的選取器,
關於jquery的css的一些知識
用類似

$("li").css("cursor","pointer");

這樣的方式來確定
具體的大家就看代碼
吧

css樣式表一

body{background:#000;
color:#fff}
h1{font-size:14px;
color:#fff;font-weight:bold;}
p{font-size:12px;
color:#fff;}

css樣式表二

body{background:#f00;color:#fff}
h1{font-size:15px;color:#fff;font-weight:bold;}
p{font-size:13px;color:#fff;}

css樣式表三

body{background:#fee;color:#000}
h1{font-size:16px;color:#000;font-weight:bold;}
p{font-size:14px;color:#000;}

主要檔案代碼

<!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"  xml:lang="utf-8">
<HTML>
<HEAD>
  <TITLE>css 選擇</TITLE>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script type="text/javascript" src="/include/jquery/jquery-1.1.3.1.pack.js"></script>
  <link href="1.css" rel="stylesheet" title="style1" type="text/css" />
  <link href="2.css" rel="stylesheet" title="style2" type="text/css" />
  <link href="3.css" rel="stylesheet" title="style3" type="text/css" />
</HEAD>
<BODY>
  <h1>jQuery 是一個新型的JavaScript庫. </h1>
  <p>jQuery是一個簡潔快速的JavaScript庫,它能讓你在你的網頁上簡單的操作文檔、處理事件、運行動畫效果或者添加Ajax互動。jQuery的設計會改變你寫JavaScript代碼的方式。
jQuery適合於設計師、開發人員以及那些還好者,同樣適合用於商業開發,可以說jQuery適合任何JavaScript應用的地方,可用於不用的應用程式。
jQuery是一個輕量級的指令碼,其代碼非常小巧,JavaScript包只有15K左右。
jQuery支援CSS1-CSS3,2881064151以及基本的xPath
jQuery是跨瀏覽器的,它支援的瀏覽器包括IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+
</p>
<ul>
<li rel="style1" class="styleswitch">styles1</li>
<li rel="style2" class="styleswitch">styles2</li>
<li rel="style3" class="styleswitch">styles3</li>
</ul>
<SCRIPT LANGUAGE="JavaScript">
<!--
$(‘.styleswitch‘).css("cursor","pointer");
$(‘.styleswitch‘).click(function()
{
switchStylestyle(this.getAttribute("rel"));
return false;
});
var c = readCookie(‘style‘);
if (c) switchStylestyle(c);
function switchStylestyle(styleName)
{
$(‘link[@rel*=style][@title]‘).each(function(i) 
{
this.disabled = true;
if (this.getAttribute(‘title‘) == styleName) this.disabled = false;
});
createCookie(‘style‘, styleName, 365);
}
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(‘;‘);
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==‘ ‘) c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name)
{
createCookie(name,"",-1);
}
//-->
</SCRIPT>
</BODY>
</HTML>

關於jquery的css的一些知識

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.