jQuery操作DOM基础

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="jquery-3.1.0.js"></script>
    <script type="text/javascript">
        $(function(){
            $("input[type='button']").click(function(){
                alert("文本框内容:"+$("input:first").attr("type"));
                alert("文本框内容:"+$("input:first").attr("placeholder"));
                $("input:first").attr("value","张柳宁");
            })
        })
    </script>
</head>
<body>
    <input type="text" placeholder="输入内容"/>
    <input type="button" value="按钮"/>
</body>
</html>

使用jQuery对象的attr()函数实现元素属性的获取的设置

原文地址:https://www.cnblogs.com/sherrykid/p/5716401.html