Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <span id='blah' onclick='showAllComment("this is a long comment to see it all", 9, true )'>this is a...</span>
- <script>
- function showAllComment( comment, shortCommentLen, showFullComment )
- {
- alert( $("#blah").html() );
- if( showFullComment )
- {
- $("#blah").html( comment );
- $("#blah").click( showAllComment( comment, shortCommentLen, false ) );
- }
- else
- {
- $("#blah").html( comment.substring( 0, shortCommentLen ) + "..." );
- $("#blah").click( showAllComment( comment, shortCommentLen, true ) );
- }
- }
- </script>
- function showAllComment( comment, shortCommentLen, showFullComment )
- {
- alert( $("#blah").html() );
- if( showFullComment )
- {
- $("#blah").html( comment );
- $("#blah").click( function () { showAllComment(comment, shortCommentLen, false);} );
- }
- else
- {
- $("#blah").html( comment.substring( 0, shortCommentLen ) + "..." );
- $("#blah").click( function () {showAllComment( comment, shortCommentLen, true );} );
- }
- }
- $(function() {
- $(".blah").each( function() {
- var shortCommentLen = 9;
- var comment = $(this).html();
- $(this).html(shortComment(comment, shortCommentLen));
- $(this).toggle(
- function() { $(this).html(comment); },
- function() { $(this).html(shortComment(comment, shortCommentLen)); }
- );
- function shortComment(comment, shortCommentLen) {
- return comment.substring( 0, shortCommentLen ) + "...";
- }
- });
- });
- <span class='blah'>this is a long comment to see it all</span>
Add Comment
Please, Sign In to add comment