jquery <a>标签得到this

参考代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        function setValue(obj) {
            $(obj).prev().val("this is world")
        }
    </script>
</head>
<body>


<div id="con">
    <nobr>
        <input type="text" placeholder="请输入值">
        <a href="#" onclick="setValue(this)">点击</a>
    </nobr>
</div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_22222499/article/details/80316540
今日推荐