Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question: Calling JQuery and plugins?

Status
Not open for further replies.

MMOgrl

Technical User
Nov 18, 2008
1
US
Question: Calling JQuery and plugins?

I am diving into javascript and I am attempting to use:

JQuery

and CrossSlide

I have created test.html to get to know javascript better. However I seem to not be calling these scripts correctly.

Can you review the code below and tell me where I am messing up? Thank you, I am usually quick to pick up on things and always eager to learn!

---

<html>
<head>
<script src='jsparty/jquery.js' type='text/javascript'></script>
<script type='text/javascript'>//<![CDATA[
$(function() {
if ($.browser.ie && $.browser.version < 8)
$('<span>&#9658;</span>').prependTo('kbd');
if ($.browser.ie && $.browser.version < 7 || $.browser.safari && $.browser.version < 600)
$('#menu a').hover(function() {
$(this).next().show();
}, function() {
$(this).next().hide();
});
});
//]]></script>

</head>
<body>

<script src='jsparty/jquery.cross-slide.js' type='text/javascript'></script>
<script type='text/javascript'>//<![CDATA[
function displaySource(name) {
$('<pre>'
+ $('#source-' + name).html() // $(<script>).text() is broken on IE 5
.replace(/^\s*|\s*$/g, '')
.split('\n').slice(2, -2).join('\n')
.replace(/( \/\/.*)/g, '<i>$1</i>')
+ '</pre>')
.insertAfter('#display-' + name);
}
//]]></script>



<script type='text/javascript' id='source-test1'>//<![CDATA[
$(function() {
$('#test1').crossSlide({
speed: 45, //in px/sec
fade: 1 //in sec
}, [
{ src: ' dir: 'up' },
{ src: ' dir: 'down' },
{ src: ' dir: 'up' },
{ src: ' dir: 'down' }
]);
});
//]]></script>

</body>
</html>
 
I don't know jQuery, and you've not given any details of nay errors or what does / doesn't work, so this is a stab in the dark... Do you need some markup on the page with relevant IDs, e.g. a container with an ID of 'test1' and one with an ID of 'menu' (your JS refers to '#test1' and '#menu')?

Also, what happens if you remove all the regexp stuff in 'displaySource' and hard-code the details for now?

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Check the following:

Is the path to jQuery correct?
Is the path to the Crosslide plugin correct?
Is there a compatible element on your page with an id of 'test1'?


Run this

Code:
$(funciton(){
    alert('jQuery has loaded');
});

This will confirm that jQuery is loading correctly

I'm not familiar with Crosslide but the syntax looks correct.

Try changing the image sources to images on the local machine.

Give details of any errors and we stand a better chance of helping.

Finally, do you have any other scripts running on the page? Remove them to see if there is a clash between them and jQuery (the first test above should rule that out but try anyway).

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top