###目的
下記コメント欄のシェアボタンで、「#」以降も含めてシェアできるようにしたいです。
html
1<h1 class="entry-title">たいとるだよ</h1> 2 3<div id="comment1"> 4 <div class="comment"> 5 <p>こんにちは!</p> 6 </div> 7 <div class="sns_wrap"> 8 <ul> 9 <li class="sns_tw"> 10 <a href="#">ツイート</a> 11 </li> 12 </ul> 13 </div> 14</div> 15 16<div id="comment2"> 17 <div class="comment"> 18 <p>さようなら!</p> 19 </div> 20 <div class="sns_wrap"> 21 <ul> 22 <li class="sns_tw"> 23 <a href="#">ツイート</a> 24 </li> 25 </ul> 26 </div> 27</div>
###試したこと
次のコードでリンクは生成できたのすが、なぜかシェア画面にいくと「#comment1」や「#comment2」の部分が消えてしまいます。
▼実際のサンプル
https://jsfiddle.net/4Ldamzj8/
ご覧のように「たいとるだよ http://example.com/test/たいとるだよ/」までしか表示されません。
これは…どうしてなのでしょうか??
直し方が分かる方がいらっしゃいましたらご教示頂けますと幸いです。
javascript
1$(function(){ 2 3 var title = $('.entry-title').text(); 4 var siteURL = 'http://example.com/test/'; 5 6 //twitter 7 $('.sns_tw a').click(function(){ 8 var id = $(this).parent().parent().parent().parent().attr('id'); 9 var link_tw = 'https://twitter.com/intent/tweet?text=' + title + '&url=' + siteURL + title + '/#' + id; 10 $(this).attr("href", link_tw); 11 }); 12 13});

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/05/21 05:38
退会済みユーザー
2018/05/21 05:47
2018/05/21 08:06
退会済みユーザー
2018/05/22 23:54