HatenaBlog beta で気にくわなかったので修正 その2
#2012_11_16 修正版のその3へ
http://raiwingprogram.hateblo.jp/entry/2012/11/16/175950
ヘッダファイル(タイトル下)に以下を記述した方が問題が発生しないかも?
<script> (function($) { //みたまま編集用 $('article.entry').each(function() { var $seemore = $(this).find('div.entry-content'); var $data = $seemore.children('p'); if ($seemore.length === 0) return; // ==== を探して それ以降の <p> にクラスを付与し、隠す var flag; flag = 0; //alert( $(this).text() ); $data.each( function(){ if( flag == 1 ){ $(this).addClass('content_hide'); $(this).hide(); } if( $(this).text() == "====" ){ flag = 1; //alert( $(this).text() ); $(this).replaceWith('<a class="next_read"> 続きを読む </a>'); //alert( $(this).text() ); } //alert( $(this).text() ); }); //div へ置き換え /* $text = ""; $data.each( function(){ $text_t = $(this).contents().text(); alert( $text_t ); $(this).replaceWith('<div>'+$text_t+'</div>'); }); */ }); })(jQuery); $( function() { //クリックを取得して表示非表示を切り替える $("a.next_read").click(function(){ $slide_data = $(this).parent('div.entry-content').children('p.content_hide'); $slide_data.slideToggle( 'fast' ); //alert( $(this).text() ); }); }); </script>