Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jquery中迭代并向每个元素添加attr_Jquery_Jquery Ui_Dom Manipulation - Fatal编程技术网

在jquery中迭代并向每个元素添加attr

在jquery中迭代并向每个元素添加attr,jquery,jquery-ui,dom-manipulation,Jquery,Jquery Ui,Dom Manipulation,我的目标是为图片添加包装样式。样式由jquery ui添加,并放置在iframe中的html中: <div class="wrapper style:"xyz"> <img id="link1"> </div> <div class="wrapper style:"abc"> <img id="link1"> </div> <div class="wrapper style:"wer"> &

我的目标是为图片添加包装样式。样式由jquery ui添加,并放置在iframe中的html中:

<div class="wrapper style:"xyz">
  <img id="link1">
</div>

<div class="wrapper  style:"abc">
   <img id="link1">
</div>

<div class="wrapper  style:"wer">
  <img id="link1">
</div>
更正您的html

范例

<div class="wrapper" style="xyz">
  <img id="link1">
</div>
<div class="wrapper" style="xyz">
  <img id="link1">
</div>
$('div.wrapper').each(function(){
    $(this).find('img').attr('style',$(this).attr('style'));
});