473,387 Members | 1,791 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,387 software developers and data experts.

How to Correctly use jQuery Scripts on the Website ?

ilya Kraft
134 100+
Hello,

I was recently reading over some cool jQuery tutorials and I decided to try and use one of them. But when I tried it it did not work. I think I did something wrong to apply it.
I will be using following tutorial as an example:
http://shakenandstirredweb.com/240/jquery-moreless-text


Alright to apply this tutorial I do the flowing:
I place this in <head> of the document

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="js/jquery-1.6.js"></script> 
  2. <script type="text/javascript" src="js/more-less.js"></script>
  3.  
This links to jQuery library and file that contains jQuery script from the tutorial.
Than in <body> section I put this (as shown in tutorial)

Expand|Select|Wrap|Line Numbers
  1. <div class="more-less">
  2.     <div class="more-block">
  3.         <p>I put long long content in here</p>
  4.     </div>
  5. </div>
  6.  
All that done and it is not working, you can see what I have got doing that here > inelmo.com
So what do I do wrong? What is the right way to use jQuery scripts from tutorials? Thank You )
May 8 '11 #1
3 2277
johny10151981
1,059 1GB
Not much idea for your problem. But it seems you had only included jquery file. but where did you call the fucntions?
what do you want to do?
how do you want to do?
more-block from where you get this class? i dont see any css file that has this definition...
May 9 '11 #2
ilya Kraft
134 100+
Hi, thank you for reply.
I guess I needed to include more information.
I mentioned this tutorials as example, if you see it you can get the idea of what I want to do.
http://shakenandstirredweb.com/240/jquery-moreless-text
So I will paste the jQuery file from tutorial, I guess My problem is that I did not call the function - So how and where do I call it? - the more-block is used by jQuery function from tutorial. Here it is:

Expand|Select|Wrap|Line Numbers
  1. $(function(){
  2.  
  3. // The height of the content block when it's not expanded
  4. var adjustheight = 80;
  5. // The "more" link text
  6. var moreText = "+  More";
  7. // The "less" link text
  8. var lessText = "- Less";
  9.  
  10. // Sets the .more-block div to the specified height and hides any content that overflows
  11. $(".more-less .more-block").css('height', adjustheight).css('overflow', 'hidden');
  12.  
  13. // The section added to the bottom of the "more-less" div
  14. $(".more-less").append('
  15. […]
  16.  
  17. ');
  18. // Set the "More" text
  19. $("a.adjust").text(moreText);
  20.  
  21. $(".adjust").toggle(function() {
  22.         $(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible');
  23.         // Hide the [...] when expanded
  24.         $(this).parents("div:first").find("p.continued").css('display', 'none');
  25.         $(this).text(lessText);
  26.     }, function() {
  27.         $(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
  28.         $(this).parents("div:first").find("p.continued").css('display', 'block');
  29.         $(this).text(moreText);
  30. });
  31. });
  32.  
I included this code in more-less.js file which I included after jQuery library.
May 9 '11 #3
JKing
1,206 Expert 1GB
You have an error in your javascript.

This is the offending piece of code Line 14-17 in your more-less.js
Expand|Select|Wrap|Line Numbers
  1. $(".more-lesss").append('
  2. […]
  3.  
  4. ');
  5.  
Put it all on one line and it should solve your problem
Expand|Select|Wrap|Line Numbers
  1. $(".more-lesss").append('[…]');
May 9 '11 #4

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

Similar topics

83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
20
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: metaphysics | last post by:
I am using a jQuery script called LocalScroll, and I have a quick problem that needs fixing. The demo for the script is here: jQuery.LocalScroll - Regular Demo, and the documentation is here: Ariel...
3
by: fjm | last post by:
I have one jquery function that submits data via a datastring to my server. This works great. On success, I currently have a little alert box that lets the user know that the data was stored. I...
13
by: neovantage | last post by:
Hey all, I have integrated a simple toggle with css and jQuery in website but it gicving jerk in IE when it hide the content. Here is the URL of the website. And it is integrated in Right Link...
0
by: amskape | last post by:
hi Friends, I need to Upload some files in a Listing , by clicking corresponding Upload link, then a popup window will come with Browse option as Shown in attachment File. My actual need is...
1
by: omar999 | last post by:
hi guys i really dont understand where i am going wrong.I've read countless articles including http://blog.nemikor.com/2009/10/03/using-multiple-versions-of-jquery/ but still having trouble with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.