[英]Add data-action to all img that contain a class
我正在使用此插件: https : //github.com/fat/zoom.js/
我想選擇所有具有img-responsive
img
類的img-responsive
,並將data-action="zoom"
到該元素。 使用jQuery是否可能? 性能會真的很差嗎?
$('img.img-responsive').data('action','zoom');
或使用jQuery.attr( attributeName, value )
,
$('img.img-responsive').attr('data-action','zoom');
只需使用
$('img[class="img-responsive"]').attr('data-action', 'zoom');
性能應該很好:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.