Javascript 如何将一群<;路径>';s

Javascript 如何将一群<;路径>';s,javascript,html,Javascript,Html,我的svg中有一堆已经有id和类的路径。如何将所有路径与一个类或id组合在一起?例如,我有以下两条路径: <path style="font-size:12px;fill:#d0d0d0;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:18.65967751;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dash

我的svg中有一堆已经有id和类的路径。如何将所有路径与一个类或id组合在一起?例如,我有以下两条路径:

  <path
     style="font-size:12px;fill:#d0d0d0;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:18.65967751;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:none"
     d="m 471.60261,246.44442 29.99111,-0.99619 8.36129,-11.40059 -0.16978,-0.49813 0.58508,-0.68252 h 1.28346 l 2.45362,1.10686 4.6997,5.90324 5.05827,15.71735 1.37784,5.53421 0.11332,0.44279 1.52883,11.1239 0.41524,4.8333 0.26423,10.23838 0.50959,34.0174 -24.17783,3.63415 -6.11526,0.16628 -15.1371,-10.57045 -25.87655,4.99926 -21.25234,27.68986 -9.45597,-12.37832 -7.04008,-9.31609 9.4371,-6.8256 10.94705,-12.63657 v -0.59033 l -1.00034,-1.73412 33.1997,-57.77781"
     id="Monmouth"
     inkscape:connector-curvature="0" />
  <path
     style="font-size:12px;fill:#d0d0d0;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:18.65967751;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:none"
     d="m 435.51515,347.70327 21.25233,-27.68984 25.87652,-4.99933 15.13713,10.57047 6.11526,-0.16629 24.17782,-3.63412 -0.0943,4.40894 1.03809,19.44377 0.32087,5.40515 1.43446,16.45523 3.75592,26.43541 0.94372,8.89177 -0.15103,0.9408 -3.8692,18.09708 -10.32419,35.49318 -4.47322,11.08704 -5.549,5.64493 -22.59243,-9.99858 2.54803,-4.29832 0.60399,-5.81096 -9.7957,-41.48865 -42.78783,-60.04694 -3.56723,-4.74101"
     id="Ocean"
     inkscape:connector-curvature="0" />


现在,我怎样才能使用选择器将这两个路径组合在一起,以便同时将javascript应用于这两个路径?

在本例中,我们将向两个路径添加
pathclass
作为类名。
var list=document.getElementsByTagName(“路径”);

对于(var i=0;i向所有要选择的路径添加相同的类,并使用jquery获取所有这些元素(
$(“.abc”)


console.log($(“.abc”))