Jump to content

dynamic tr td height


GD77

Recommended Posts

ok i m here now:

<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
  $("#tog").click(function(){
    $("li").toggle();
  });
});
</script>
</head>
<body>

<div id='tog'>Toggle</div>
<ul>
<li>text 1.</li>
<li>text 2.</li>
<li>text 3.</li>
</ul>

how to exclude the first type of <li> ?

Link to comment
Share on other sites

found this online:

 

<div class="item">
    Text goes in here.
</div>

$(function(){ /* to make sure the script runs after page load */

$('.item').each(function(event){ /* select all divs with the item class */

	var max_length = 150; /* set the max content length before a read more link will be added */

	if($(this).html().length > max_length){ /* check for content length */

		var short_content 	= $(this).html().substr(0,max_length); /* split the content in two parts */
		var long_content	= $(this).html().substr(max_length);

		$(this).html(short_content+
					 '<a href="#" class="read_more"><br/>Read More</a>'+
					 '<span class="more_text" style="display:none;">'+long_content+'</span>'); /* Alter the html to allow the read more functionality */

		$(this).find('a.read_more').click(function(event){ /* find the a.read_more element within the new html and bind the following code to it */

			event.preventDefault(); /* prevent the a from changing the url */
			$(this).hide(); /* hide the read more button */
			$(this).parents('.item').find('.more_text').show(); /* show the .more_text span */

		});

	}

});


});

 

Can we have it to toggle plz?

Link to comment
Share on other sites

ok Solved it with the following:

<div class="more-less">
    <div class="more-block">
    	long text.......
    </div>
</div>

$(function(){

// The height of the content block when it's not expanded
var adjustheight = 80;
// The "more" link text
var moreText = "+  More";
// The "less" link text
var lessText = "- Less";

// Sets the .more-block div to the specified height and hides any content that overflows
$(".more-less .more-block").css('height', adjustheight).css('overflow', 'hidden');

// The section added to the bottom of the "more-less" div
$(".more-less").append('<p class="continued">[…]</p><a href="#" class="adjust"></a>');

$("a.adjust").text(moreText);

$(".adjust").toggle(function() {
	$(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible');
	// Hide the [...] when expanded
	$(this).parents("div:first").find("p.continued").css('display', 'none');
	$(this).text(lessText);
}, function() {
	$(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
	$(this).parents("div:first").find("p.continued").css('display', 'block');
	$(this).text(moreText);
});
});


 

Found it somewhere hope someone needs it one day too.

Thanks again for anyone tried to help :D

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.