473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Editing the script to not start if div height is not bigger than in script

ilya Kraft
134 100+
Hi,

I couldn't fit this in a title, but here is what I need. I have a script that looks at height of a div and if it is more than 80 the script adds "More" button at the end so div initially displays with height of 80, but when someone clicks "More" button it shows all div. After they expand div there is a "Less" button to make it 80px high again. When div is not expanded there is [...] at the end of a text that indicates that there is more text.

Right now I need to somehow edit the script so if the height is less then 80 it will not add "More" and [...] and keep it as it is. Does anyone have any ideas on how to edit it to not do that when not needed?

Here is javascript:
Expand|Select|Wrap|Line Numbers
  1. $(function(){
  2. var adjustheight = 80;
  3. var moreText = "More";
  4. var lessText = "Less";
  5. $(".more-less .more-block").css('height', adjustheight).css('overflow', 'hidden');
  6. $(".more-less").append('<p class="continued">[&hellip;]</p><a href="#" class="adjust"></a>');
  7. $("a.adjust").text(moreText);
  8. $(".adjust").toggle(function() {
  9.         $(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible').slideDown("slow");
  10.         $(this).parents("div:first").find("p.continued").css('display', 'none');
  11.         $(this).text(lessText);
  12.     }, function() {
  13.         $(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
  14.         $(this).parents("div:first").find("p.continued").css('display', 'block');
  15.         $(this).text(moreText);
  16. });
  17. });
  18.  
And this are div's that .js script looks for.
Expand|Select|Wrap|Line Numbers
  1. <div class="more-less">
  2. <div class="more-block">
  3. <p>Random story here</p>
  4. </div>
  5. </div>
  6.  
Jun 26 '11 #1
0 1142

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not...
0
by: Mad Scientist Jr | last post by:
I am editing an existing application that has a System.Windows.Forms.TreeView with a right-click menu with several options. I want to get rid of the TreeView alltogether and rip out the code for...
4
by: dsimmons | last post by:
On my website http://seasidequilters.blogspot.com/ I'm having a problem that someone thinks might be associated with Firefox browsers. I'm hoping to find someone in this forum that might be...
3
by: Learner | last post by:
Hello, I have two buttons on one of my VehicleDetails.aspx page. Obiviously these two buttons takes the user to two different pages. Now my client is interested in having a linkbutton instead of...
0
by: TonyHa | last post by:
Hello I have install Python 2.5 under an user directory "/user/dtgtools/packages/python/2.5" after installation python works ok. but when I try "idle" I have the following Error message: **...
2
by: webgrrlie | last post by:
Script: DD Tab Content Script http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm Please help! I need your expertise with this in order to get it up and running ASAP... A colleague at my...
1
by: jonathan184 | last post by:
how to monitor and find out if files test1_* and test2_* files were sent in an hour and if not send an email This is on a unix system basically I got a cronjob that runs every sec polling a ftp dir...
3
by: khurramhameed7 | last post by:
Hi, I am new here i need help in my script, all the things are working fine the only problem is that when user click on <div class="addButton"><a...
0
by: vitugv | last post by:
I have been trying to run the following script to set and export env variables but I can't get it to work. ( on both RHEL 3 and 4). export ORACLE_SID=infra export ORACLE_HOME=$HOME/infra...
10
by: blackice | last post by:
Hello all this thread ihttp://www.thescripts.com/forum/thread50290.html contains what i need but i cannot understand some of the code i need more explain .... my $sampleinput = <<"EOF"; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.