jQuery操作属性的方法

Original 2018-11-30 01:35:03 203
abstract:<!DOCTYPE html><html><head> <title>jQuery操作属性的方法</title> <script type="text/javascript" src="jquery-3.3.1.min.js"></script> <style type

<!DOCTYPE html>

<html>

<head>

<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 type="text/javascript">

$(document).ready(function () {

// $('p').addClass('box main');//多个class用空格分开

// $('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($('b,span').text());

$('span').text('大家好,我是吴dddddddd');

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

$('p').html('<h1>新加一的H1标签</h1>');

//alert($('input').val());

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

})


</script>

<!-- <p title="content">PHP中文网</p>

<img src="jquery/images/1.jpg">

<button>点击删除图片</button>

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

<button>点击</button> -->

<span>大家好,我是老总</span><br>

<b>欢迎来到</b>

<p>php中文网</p>

<button>点击切换</button>

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


</body>

</html>


Release Notes

Popular Entries