Javascript 仅当JQuery中有2个具有相同名称时才更改第一个属性

Javascript 仅当JQuery中有2个具有相同名称时才更改第一个属性,javascript,jquery,Javascript,Jquery,所以我到处都找不到答案 thisObj.$playpauseButton.find('svg').attr('viewBox',newSvgData[0]); <svg focusable="false" aria-hidden="true" viewBox="-40 -130 500 600" viewbox="-28 -140 500 600"> thisObj.$playbausebutton.find('svg').attr('viewBox',newSvgData[0]

所以我到处都找不到答案

thisObj.$playpauseButton.find('svg').attr('viewBox',newSvgData[0]);

<svg focusable="false" aria-hidden="true" viewBox="-40 -130 500 600" viewbox="-28 -140 500 600">
thisObj.$playbausebutton.find('svg').attr('viewBox',newSvgData[0]);
此处的代码仅更改最后一个viewbox属性,而不是两个,
如何选择两者或仅选择第一个?

我找到了一种解决方法,可以使用setAttribute(),因为它区分大小写

您也可以使用jQuery

现在,您的脚本应该如下所示

$('.able-button-handler-play').find('svg').eq(0).setAttribute('viewBox','-28 -140 500 600');
$('.able-button-handler-play').find('svg').eq(0).setAttribute('viewBox','-28 -140 500 600');