亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQuery操作屬性方法總結(jié)

asal 2019-01-06 21:11:49 300
abstrak:<!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&quo

<!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操作屬性的方法</title>

<script type="text/javascript" src="jquery-3.3.1.min.js"></script>

<style type="text/css">

<!--<!--.box{color:red;} -->

.main{font-size:40px; font-weight:bold;} -->

.bb{color: red;}

</style>

</head>


<body>

<script>

$(function(){

//$('p').addClass('box main')

//$('p').removeClass('box main')

//alert($('p').attr('title'))

//$('p').attr('title','你好')

//alert($('p').attr('title'))

//$('button').click(function(){$('img').removeAttr('src')})

//$('button').click(function(){


// alert($('div').hasClass('one'))

// })


$('button').click(function(){

//$('span,b,p').toggleClass('bb')

//alert($('p').html())

//$('b').html('<h1>hello</h1>')

$('input').val('我是被修改的值')

})


//alert($('span').text(''))

//$('span').text('你好')


})


</script>


<!--<p title="content">php中文網(wǎng)</p> -->


<!--<img src="1.jpg">

<button>點擊刪除圖片</button> -->

<!--<div class="one">你好</div>

<button>點擊</button> -->

<span>大家好</span>

<b>來到</b>

<p>中文網(wǎng)</p>


<button>點擊切換</button>

<input type="text" name="" value="我是元素的值">

</body>

</html>



<!--操作屬性方法總結(jié)


獲取并設(shè)置css類

addClass()  注意C為大寫  添加

$(function(){


 $("button").click(function(){

    $("h1,h2,p").addClass("blue");

    $("div").addClass("important");

})



removeClass()  移除

<script>

$(document).ready(function(){

  $("button").click(function(){

    $("h1,h2,p").removeClass("blue");

  });

});

</script>


toggleClass()  添加/刪除  點擊一次添加 再點擊一次刪除


<script>

$(document).ready(function(){

  $("button").click(function(){

    $("h1,h2,p").toggleClass("blue");

  });

});

</script>


css()



attr() 設(shè)置或返回


removerAttr() 選中中移除


hasClass()  檢查選中是否包含


text()


html()


val() 返回或設(shè)置被選中


 -->





Nota Keluaran

Penyertaan Popular