jQuery實(shí)例—選項(xiàng)卡的簡(jiǎn)單實(shí)現(xiàn)(js源碼和jQuery)
分別利用javascript的源碼和jQuery來(lái)實(shí)現(xiàn)一個(gè)簡(jiǎn)單的選項(xiàng)卡,對(duì)比各自的步驟。
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery實(shí)例—選項(xiàng)卡的簡(jiǎn)單實(shí)現(xiàn)(js源碼和jQuery) </title>
<style>
div{
display:none;
width:50px;
height:50px;
border:1px solid red;
}
.active{
display:block;
}
.back{
background:red;
}
</style>
<script type="text/javascript" src="jquery-1.12.3.min.js"></script>
<script>
//javascript源碼寫(xiě)
/*window.onload=function(){
var aInput=document.getElementsByTagName('input');
var aDiv=document.getElementsByTagName('div');
for(var i=0;i<aInput.length;i++){
aInput[i].index=i;
aInput[i].onclick=function(){
for(var i=0;i<aInput.length;i++){
aInput[i].className='';
aDiv[i].style.display='none';
}
this.className='back';
aDiv[this.index].style.display='block';
}
}
};*/
//jQuery寫(xiě)
$(function(){
$('input').click(function(){
$('input').attr('class','');
$('div').css('display','none');
$(this).attr('class','back');
$('div').eq($(this).index()).css('display','block');
});
});
</script>
<script>
</script>
</head>
<body>
<input type="button" value="1" />
<input type="button" value="2" />
<input type="button" value="3" />
<div class="active">111</div>
<div>222</div>
<div>333</div>
</body>
</html>

以上這篇jQuery實(shí)例—選項(xiàng)卡的簡(jiǎn)單實(shí)現(xiàn)(js源碼和jQuery) 就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- jquery插件tytabs.jquery.min.js實(shí)現(xiàn)漸變TAB選項(xiàng)卡效果
- 原生js和jQuery寫(xiě)的網(wǎng)頁(yè)選項(xiàng)卡特效對(duì)比
- 簡(jiǎn)單選項(xiàng)卡 js和jquery制作方法分享
- js/jQuery簡(jiǎn)單實(shí)現(xiàn)選項(xiàng)卡功能
- 結(jié)構(gòu)/表現(xiàn)/行為完全分離的選項(xiàng)卡(jquery版和原生JS版)
- JQuery 選項(xiàng)卡效果(JS與HTML的分離)
- 原生JS與jQuery編寫(xiě)簡(jiǎn)單選項(xiàng)卡
相關(guān)文章
jQuery實(shí)現(xiàn)灰藍(lán)風(fēng)格標(biāo)準(zhǔn)二級(jí)下拉菜單效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)灰藍(lán)風(fēng)格標(biāo)準(zhǔn)二級(jí)下拉菜單效果代碼,涉及jquery鼠標(biāo)mouseover事件控制頁(yè)面元素樣式動(dòng)態(tài)變換的實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
jQuery實(shí)現(xiàn)的簡(jiǎn)單拖拽功能示例【測(cè)試可用】
這篇文章主要介紹了jQuery實(shí)現(xiàn)的簡(jiǎn)單拖拽功能,涉及jQuery基于事件響應(yīng)及頁(yè)面元素屬性動(dòng)態(tài)操作實(shí)現(xiàn)拖拽功能的相關(guān)操作技巧,需要的朋友可以參考下2018-08-08
jQuery實(shí)現(xiàn)中獎(jiǎng)播報(bào)功能(讓文本滾動(dòng)起來(lái)) 簡(jiǎn)單設(shè)置數(shù)值即可
這篇文章主要介紹了jQuery實(shí)現(xiàn)中獎(jiǎng)播報(bào)功能(讓文本滾動(dòng)起來(lái)) 簡(jiǎn)單設(shè)置數(shù)值即可,文中通過(guò)實(shí)例代碼給大家詳細(xì)介紹,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03
完美兼容各大瀏覽器的jQuery插件實(shí)現(xiàn)圖片切換特效
網(wǎng)友zoeDylan寫(xiě)的原創(chuàng)jquery插件,實(shí)現(xiàn)了圖片輪播功能,jquery插件名稱為zoeDylan.ImgChange,圖片路徑、跳轉(zhuǎn)鏈接、提示標(biāo)題都是有動(dòng)態(tài)數(shù)組來(lái)配置,jquery插件可靈活配置6個(gè)參數(shù), height高、width寬、mgs圖片地址、links點(diǎn)擊地址、tips圖片說(shuō)明、timers自動(dòng)切換時(shí)間,2014-12-12
jquery實(shí)現(xiàn)走馬燈特效實(shí)例(撲克牌切換效果)
本文主要介紹了jquery實(shí)現(xiàn)走馬燈特效實(shí)例(撲克牌切換效果),文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02
jQuery向上遍歷DOM樹(shù)之parents(),parent(),closest()之間的區(qū)別
這篇文章主要是對(duì)jQuery向上遍歷DOM樹(shù)之parents(),parent(),closest()之間的區(qū)別進(jìn)行了詳細(xì)的介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-12-12
jquerymobile checkbox及時(shí)刷新才能獲取其準(zhǔn)確值
一般登錄的時(shí)候 都有個(gè)記住用戶名 記住密碼 的兩個(gè)checkbox 多選框用jquerymobile 做頁(yè)面 ,當(dāng)勾選checkbox 時(shí)總是不能獲取它正確的值2012-04-04
基于jquery實(shí)現(xiàn)智能表單驗(yàn)證操作
這篇文章主要為大家詳細(xì)介紹了基于jquery實(shí)現(xiàn)智能表單驗(yàn)證操作的相關(guān)資料,利用jquery實(shí)現(xiàn)了對(duì)一個(gè)表單字段格式的即時(shí)檢查,感興趣的小伙伴們可以參考一下2016-05-05

