Добрый день уважаемые. Вот нужна ваша помощь в таком вопросе.
Есть очень много элементов path (100 если быть точным) мне необходимо в консоль вычисти сначала чему равняется их атрибут d=""
а затем в консоль вывести этот же атрибут но уже с изменениями в перестановке.
<path id="k3" class="st0" d="M347.6,357.3 358.6,369.5 358.9,424.7 353.4,424.8 "/>
в консоль надо вывести такое
1) k3 d="M347.6,357.3 358.6,369.5 358.9,424.7 353.4,424.8 "
2) k3 d="M347.6,357.3 358.6,369.5 358.9,424.7 353.4,424.8 358.9,424.7 358.6,369.5 347.6,357.3" Для каждого id
как видbте закономерность тут такая - что в массиве d к последнему элементу прибавляется предыдущий и тд. пока не дойдет до первого. Первый добавляется без буквы M. Подскажите как написать такой цикл?
Код приведу
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>
<div class="direct">
<!-- DIRECTION -->
<path id="k100" class="st0" d="M143.2,277.4 129.1,277.5"/>
<path id="k99" class="st0" d="M143,246.8 166.4,259.5 166.6,301.2 154.9,301.3 154.8,266.3 "/>
<path id="k98" class="st0" d="M126.3,301.5 143.3,301.4 143.3,311.8 166.6,311.7 "/>
<path id="k97" class="st0" d="M174.4,321.4 174,260.1 192.6,238.5 208.6,238.5 208.5,219.5 216.4,208.4 "/>
<path id="k96" class="st0" d="M185.4,227.5 201.2,227.5"/>
<path id="k95" class="st0" d="M193.3,227.5 210.8,202.3 210.7,167.3 "/>
<path id="k94" class="st0" d="M201.9,185.1 201.8,160.6 210.6,148.9 210.5,133 "/>
<path id="k93" class="st0" d="M241.3,37.8 241.3,51.9 254.3,62.2 254.5,97.2 238.6,106.5 238.7,137.7 "/>
<path id="k92" class="st0" d="M229.4,112.6 229.6,148.8 246.8,148.7 246.8,160.1 265.2,160 265.5,211.8 255.1,222.9
255.3,256 "/>
<path id="k91" class="st0" d="M238.9,163.5 222.3,163.6 222.2,142 210.4,117.6 "/>
<path id="k90" class="st0" d="M165.2,42.4 173,63.9 205.9,93.7 206,112.4 222,112.4 "/>
<path id="k89" class="st0" d="M231.5,37.8 231.5,51.9 246.3,67.2 246.4,90.2 231.8,96.7 "/>
<path id="k88" class="st0" d="M229.3,104 215.9,104.1 215.8,84.2 205.8,84.2 "/>
<path id="k87" class="st0" d="M217.3,37.9 217.4,56.3 238.4,70.3 "/>
<path id="k86" class="st0" d="M238.4,84.1 221.9,93.7 221.8,70.4 234.1,77.2 "/>
<path id="k85" class="st0" d="M215.7,75.9 215.6,63 205.7,60 205.6,37.9 "/>
<path id="k84" class="st0" d="M172.9,42.4 176.4,60.2 186.2,60.1 186.1,38 "/>
<path id="k83" class="st0" d="M194.2,38 194.4,67.4 186.2,67.5 201.3,67.4 201.3,77.4 210.7,77.3 "/>
<path id="k82" class="st0" d="M254.8,170.2 235.8,170.2 236,205.2 225,215.1 225.1,227.3 216.5,227.4 "/>
<path id="k81" class="st0" d="M224.8,170.3 224.9,192.4 218.1,198.6 "/>
<path id="k80" class="st0" d="M254.9,181.3 255,208.5 244,208.5 243.9,181.4 "/>
<path id="k79" class="st0" d="M235.8,219.3 247.7,219.3 247.3,255.4 236,255.5 235.8,227.3 "/>
<path id="k78" class="st0" d="M218.3,235 206.7,249.8 206.8,274 218.5,277.1 218.7,306.2 "/>
<path id="k76" class="st0" d="M207,306.2 206.8,283.9 195.4,277.2 195.3,246.8 180.7,266.2 181,321.4 193.1,321.3 "/>
<path id="k75" class="st0" d="M195.6,314 187.5,314 187.3,277.2 195.5,288.8 195.6,301.1 "/>
<path id="k74" class="st0" d="M225.1,237.5 216.6,255.6 216.7,268.8 228.9,268.7 225.2,255.6 "/>
<path id="k73" class="st0" d="M225.5,300.9 225.3,277 239.4,276.9 239.5,283.7 "/>
<path id="k72" class="st0" d="M231.2,288.6 231.2,297.6 250,297.7 261.8,330.8 "/>
<path id="k71" class="st0" d="M236,264.7 255.3,264.6 255.5,288.8 244.3,273.5 "/>
<path id="k70" class="st0" d="M254.7,153.9 254.6,132.7 245,132.8 244.9,117.5 268.6,106.3 268.5,93.9 260.6,93.5
260.4,53.9 251.1,37.7 "/>
<path id="k69" class="st0" d="M274.1,345.5 274,320.9 266,313.6 265.7,252.9 277.8,252 "/>
<path id="k68" class="st0" d="M265.6,242.5 265.5,225.3 277.2,225.2 277.3,242.4 "/>
<path id="k67" class="st0" d="M277.4,261.4 277.6,311.1 287,330.7 282.5,357.7 "/>
<path id="k66" class="st0" d="M425.7,125.4 379.7,126 371.7,116.8 323.9,117 315.3,111.9 "/>
<path id="k65" class="st0" d="M417.1,116.6 385.2,118.7 375.3,105.7 331.8,106 331.7,96.2 297.4,96.3 297.5,122.7
303.7,129.4 "/>
<path id="k64" class="st0" d="M406.6,105.6 385.7,105.7 389.5,112.4 399.9,112.4 "/>
<path id="k63" class="st0" d="M344.6,96.1 396.1,95.8"/>
<path id="k62" class="st0" d="M306,96.3 306.1,120.2 319,126.3 297.7,147.2 297.8,166.9 "/>
<path id="k61" class="st0" d="M249,115.5 265,129.6 265.2,153.8 "/>
<path id="k60" class="st0" d="M271,153.8 271.1,181.3 281.6,181.2 281.8,216.6 273.5,216.7 274,194.8 "/>
<path id="k59" class="st0" d="M264.6,37.6 281,67 281.5,145.9 273.2,137.6 273.1,115.4 265,115.4 "/>
<path id="k58" class="st0" d="M268.4,64 268.5,83.9 281.1,83.8 "/>
<path id="k57" class="st0" d="M289.6,134.5 289.9,181.2 329.1,181 348,166.6 "/>
<path id="k56" class="st0" d="M308.5,173.9 327.2,173.8 344.9,156.8 376.8,155.7 376.7,141.2 366.9,134.1 366.2,125.7
330,126.2 "/>
<path id="k55" class="st0" d="M322.7,134.3 328.9,141.4 342.5,137.2 371.8,137.6 "/>
<path id="k54" class="st0" d="M303.8,148.4 376.8,146.8"/>
<path id="k53" class="st0" d="M332.1,147.6 322.9,166.7 308.5,166.8 308.4,156.1 318.9,156 "/>
<path id="k52" class="st0" d="M391.2,87 366,87.1 351.8,73.5 367.8,73.4 "/>
<path id="k51" class="st0" d="M354.4,89.6 339.9,73.6 297.3,75.5 297.2,53.7 303.3,45.4 "/>
<path id="k50" class="st0" d="M289.1,41.8c0,1.8,0.3,64.4,0.3,64.4"/>
<path id="k49" class="st0" d="M289.4,85.3 332.3,84.2 336.6,93.1 "/>
<path id="k48" class="st0" d="M347.5,63.6 308,67.6 303.3,56.4 312.8,53.6 "/>
<path id="k47" class="st0" d="M325.4,57"/>
<path id="k46" class="st0" d="M385.9,134c0-0.7,42.9-0.2,42.9-0.2l0.1,15.5l-42.9,3.9l-0.1-12.1l28.2,1.5"/>
<path id="k45" class="st0" d="M440.5,147.7 440.7,181.4 450.6,191.2 450.8,241.5 "/>
<path id="k44" class="st0" d="M441.1,260.6 440.8,197.7"/>
<path id="k43" class="st0" d="M440.9,218.2 429.3,218.3 429.2,197.8 404,197.6 "/>
<path id="k42" class="st0" d="M429.3,218.3 429.4,241.6 407.3,241.7 407.4,255.2 "/>
<path id="k41" class="st0" d="M422.2,162.5 410,162.6 410.1,186.5 372.1,186.7 366,198.1 366.2,232.7 401.1,234.1 "/>
<path id="k40" class="st0" d="M386.2,191.5c0.6,3.1,0.1,27,0.1,27l8,7.9l35-0.2"/>
<path id="k39" class="st0" d="M386,204.4 374.6,204.5 374.7,224.7 "/>
<path id="k38" class="st0" d="M386.4,214.5 411.5,214.4"/>
<path id="k37" class="st0" d="M433.1,160.5 433.3,185.5"/>
<path id="k36" class="st0" d="M418.1,185.8 431.5,186.4"/>
<path id="k35" class="st0" d="M403.8,166.3 391.6,178.9 360.7,179.5 362.3,245.6 399.1,245.4 "/>
<path id="k34" class="st0" d="M403.8,159.6 362.1,162.8 332.8,186.9 "/>
<path id="k33" class="st0" d="M352.4,170.9 385.9,170.7"/>
<path id="k32" class="st0" d="M291.7,192 323,191.9 332.9,202.2 352.5,202.1 352.6,224.8 "/>
<path id="k31" class="st0" d="M326.2,205.3 290,206.5 289.9,198.2 "/>
<path id="k30" class="st0" d="M291.9,215 342.9,214.8 343,236.8 352.7,236.8 "/>
<path id="k29" class="st0" d="M286.4,225.2 333,224.9 333.1,242.1 286.5,242.4 286.5,234.7 316,234.2 "/>
<path id="k28" class="st0" d="M286.5,249.4 286.8,305.8 298.4,317.3 "/>
<path id="k27" class="st0" d="M290.6,320.8 298.6,336.7 298.7,349 366.8,348.6 "/>
<path id="k26" class="st0" d="M370,340.7 371.5,313.1 418.7,308.8 "/>
<path id="k25" class="st0" d="M408.3,320.2 377.7,320.4 377.7,334.5 386.7,340.6 "/>
<path id="k24" class="st0" d="M386.7,330.1 399.5,330.1"/>
<path id="k23" class="st0" d="M437.5,272.8 417.9,265 417.8,248.7 "/>
<path id="k22" class="st0" d="M418.4,257.6 429.5,257.6"/>
<path id="k21" class="st0" d="M432.1,293.7 422.9,287.6 422.8,275.8 392.1,261 392,252.2 "/>
<path id="k20" class="st0" d="M343.1,245.7 345.4,258 381.2,257.8 381.3,276.1 "/>
<path id="k19" class="st0" d="M328.2,252.6 328.3,268.2 369.6,268 "/>
<path id="k18" class="st0" d="M319.3,249.2 298,249.3 296,294.4 304.6,313.4 "/>
<path id="k17" class="st0" d="M308,341 348.3,340.8 362.5,330.6 362.4,300.2 386.8,300.1 "/>
<path id="k16" class="st0" d="M399.4,300 422.9,299.9 408.2,288 408.1,278.5 392.1,271.5 "/>
<path id="k15" class="st0" d="M397.1,285.8 372.6,285.9 369.7,276.3 340.9,276.4 "/>
<path id="k14" class="st0" d="M366.5,294.1 353,294.1 353.2,327.3 "/>
<path id="k13" class="st0" d="M307.9,325.2 353.1,317"/>
<path id="k12" class="st0" d="M309.9,261.2 310,283.2 359.7,283 "/>
<path id="k11" class="st0" d="M345.6,283.3 345.7,309.2"/>
<path id="k10" class="st0" d="M345.7,300.3 319.7,317.2"/>
<path id="k9" class="st0" d="M304.5,294.4 345.6,294.2"/>
<path id="k8" class="st0" d="M314.1,295 314.1,308.8 323.1,300.4 "/>
<path id="k7" class="st0" d="M341.2,319.2 341.2,334.7 316.4,334.8 327.1,327.4 "/>
<path id="k6" class="st0" d="M290.8,357.6 308.9,357.5 309,387.6 "/>
<path id="k5" class="st0" d="M316.8,401.7 316.6,367.9 327,364.2 326.9,348.9 "/>
<path id="k4" class="st0" d="M332.9,348.8 333.7,363.5 346,372.4 346.4,438.3 "/>
<path id="k3" class="st0" d="M347.6,357.3 358.6,369.5 358.9,424.7 353.4,424.8 "/>
<path id="k2" class="st0" d="M335.4,382.5 335.5,415 329.8,415 324.1,391.2 "/>
<path id="k1" class="st0" d="M362.7,357.3 371.7,357.2"/>
<!-- DIRECTION END -->
</div>
<script>
window.onload = function() {
console.log("length = " + $('.direct path').length);
var len = $('.direct path').length;
for (var i = 1; i <= len +1 ; i++) {
console.log( "k" + i + " = " + '$(' + "#k" + i + ')' + '.attr("d")' );
}
}
</script>
</body>
</html>