82550495 2020-03-05
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>18-attr和prop的练习</title> <script src="../js/jquery-1.12.4.js"></script> <script> $(function () { //1.给我们的按钮天界点击事件 var btn=document.getElementsByTagName("button")[0]; btn.onclick=function () { //2.获取输入框输入的内容 var input=document.getElementsByTagName("input")[0]; var text=input.value; //3.修改img的src属性节点的值 // $("img").attr("src",text); $("img").prop("src",text); } }) </script></head><body><input type="text"><button>切换图片</button><br><img src="https://www.baidu.com/img/bd_logo1.png" ></body></html>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%&qu