回答編集履歴

1

chousei

2018/12/11 05:07

投稿

yambejp
yambejp

スコア114829

test CHANGED
@@ -49,3 +49,81 @@
49
49
  ※上記、2108は10が先に反応して2十8→二十八になります、
50
50
 
51
51
  仕様をよくよく検討してください
52
+
53
+
54
+
55
+ # 縦横切替
56
+
57
+ ```javascript
58
+
59
+ <style>
60
+
61
+ div.tategaki {
62
+
63
+ -webkit-writing-mode: vertical-rl;
64
+
65
+ -ms-writing-mode: tb-rl;
66
+
67
+ writing-mode: vertical-rl;
68
+
69
+ float:right;
70
+
71
+ }
72
+
73
+ </style>
74
+
75
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
76
+
77
+ <script>
78
+
79
+ var henkanhyo={
80
+
81
+ "0":"〇","1":"一","2":"二","3":"三","4":"四","5":"五","6":"六","7":"七","8":"八","9":"九",
82
+
83
+ "0":"〇","1":"一","2":"二","3":"三","4":"四","5":"五","6":"六","7":"七","8":"八","9":"九",
84
+
85
+ }
86
+
87
+ $(function(){
88
+
89
+ $('.contents').each(function(){
90
+
91
+ $(this).data('yokogaki',$(this).text());
92
+
93
+ var v=$(this).text();
94
+
95
+ v=v.replace(/1(?=[1-9])|1(?=[1-9])|10|10/g,"十").replace(/[0-9]|[0-9]/g,function(x){return henkanhyo[x]});
96
+
97
+ $(this).data('tategaki',v);
98
+
99
+ });
100
+
101
+ $('[name=shosiki]').on('change',function(){
102
+
103
+ if($(this).val()=='tategaki'){
104
+
105
+ $('.contents').addClass('tategaki').removeClass('yokogaki').text(function(){return $(this).data('tategaki');});
106
+
107
+ }else{
108
+
109
+ $('.contents').removeClass('tategaki').addClass('yokogaki').text(function(){return $(this).data('yokogaki');});
110
+
111
+ };
112
+
113
+ }).filter(':checked').trigger('change');
114
+
115
+ });
116
+
117
+ </script>
118
+
119
+ <label><input type="radio" name="shosiki" value="tategaki" checked>縦書き</label>
120
+
121
+ <label><input type="radio" name="shosiki" value="yokogaki">横書き</label>
122
+
123
+ <div class="contents">「あああ」2018年7月17日ー11月28日</div>
124
+
125
+ <div class="contents">2018年3月15日ー12月25日:2108年3月31日</div>
126
+
127
+
128
+
129
+ ```