jQuery
[jQuery] $.fn.reverse - 확장집합 역순으로 정렬
힘없는염소
2015. 2. 5. 10:34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <script src="js/jquery.js"></script> </head> <body> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> </ul> <script> $.fn.reverse = [].reverse; //선택된 확장집합을 역순으로... 새로운 jquery 메서드를 만듬 // 또는 $(li).get().reverse(); var li = $('li'); console.log(li.text()); li.reverse(); console.log(li.text()); </script> </body> </html> |
반응형