我试图从 img 标签中获取 data-target 属性
html:
<img src="my src" alt="my_alt" data-target= "my_target1" />
<img src="my src" alt="my_alt" data-target= "my_target2" />
<img src="my src" alt="my_alt" data-target= "my_target3" />
<img src="my src" alt="my_alt" data-target= "my_target4" />
红宝石:
my_html.css("img").each do |img|
puts img[:src]
puts img[:data-target]
end
img[:src] 工作正常,但 img[:data-target] 的情况并非如此