2025年02月18日 建站教程
jquery如何获取img图片中的src属性,下面web建站小编给大家介绍一下实现代码!
利用attr实现代码:
$(document).ready(function() {
  $("button").click(function() {
    var img = $("img").prop("src");
    console.log("输出结果:" + img)
  });
});
利用prop实现代码:
$(document).ready(function() {
  $("button").click(function() {
    var img = $("img").attr("src");
    console.log("输出结果:" + img)
  });
});
			
                                        本文链接:http://so.lmcjl.com/news/23403/