Understanding XHTML Slide Show w/ Javascript & jQuery

  • Thread starter jeff1evesque
  • Start date
In summary, the conversation is about the use of javascript and jquery in web design. The speaker is seeking clarification on certain terms and functions used in the code, such as the use of the $ symbol, single quotes, and the li:gt(0) notation. They also inquire about the addClass and .attr functions and ask for a reference website. The expert summarizes the code and explains that it is using jquery to create a slideshow. They also provide explanations for the various terms and functions used in the code and suggest a website for further reference. The speaker expresses their gratitude for the clarification and mentions their intention to use the code to improve their own webpage.
  • #1
jeff1evesque
312
0
I have this script on one of my webpages that is used to create a slideshow. The code works, however, I am not familiar with javascript- that is used for web design. I have studied java for basic programming, but have never seen the notation $, nor the use of a single quote for the argument '.slideList li:gt(0)'. Could someone also explain to me what li:gt(0) means (I've never seen the use of semi colons in java like this before), the addClass funtion, along with the .attr function.

If there is a website I could reference these terms, perhaps that would be best.

$('.slideList li:gt(0)').hide();

--------------------------------------------------------------------------------------
This is the full set of code:
--------------------------------------------------------------------------------------
<ul class="slideList">
<li><img src="PICTURES/"
alt = "We will soon be incorporating a slide show..."></img></li>
<li><img src="PICTURES/"
alt = "... however, we are still undergoing some
other modifications."></img></li>
<li><img src="PICTURES/"
alt = "Since we are a small firm, we are still studying some basic
concepts..."></img></li>
<li><img src="PICTURES/"
alt = "...these concepts will be incorporated on our site in the
near future."></img></li>
</ul>

<script type = "text/javascript" src =
"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type = "text/javascript">
$('.slideList li:gt(0)').hide();
$('.slideList li:last').addClass('last');
var cur = $('.slideList li:first');

function animate()
{
cur.fadeOut( 1000 );
if ( cur.attr('class') == 'last' )
cur = $('.slideList li:first');
else
cur = cur.next();

cur.fadeIn( 1000 );
}

$(function( )
{
setInterval( "animate()", 5000 );
});
</script>-------------------------------------------------------------------------------------
In my CSS file I have:
-------------------------------------------------------------------------------------
ul.slideList
{
position: relative; left: 150px; /* See definitions below (#8) */
}

.slideList li {
list-style-type: none; /*Gets rid of bullets next to image/text*/
position: absolute; /* See definitions below (#9) */
}

.slideList img {
border: 1px solid #e7e7e7;
padding: 5px;
background-color: #ececec;
}

Thanks,JL
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Yeah, this is jquery stuff. They have the jquery engine referenced: <script type = "text/javascript" src = "http://ajax ... jquery/1.3.2/jquery.min.js"></script>

jquery creates an object, named $. Then they pass strings such as '.slideList li:first' into the object which they then parse.

.slideList li:first is actually CSS notation. Actually, it's jquery's paraphrased flavour of CSS notation li:first-child

:first is a pseudo-class; it means the first child.

Look up http://www.w3schools.com/css/pr_pseudo_first-child.asp" .


gt(0) is a call to a function that returns all elements with an index higher than <n>, in this case, 0.

So, '.slideList li:gt(0)').hide(); hides all li elements.

http://docs.jquery.com/Selectors/gt"


http://docs.jquery.com/Attributes/addClass" is a generic jquery function that ... well ... adds a class to a tag. In this case, it is locating the last li in the ul using the :last-child pseudo-class (which some browsers, but not all, can do) and explicitly gives it a class, called "last".
i.e.:
Code:
<ul class="slidelist">
  <li></li>
  <li></li>
</ul>
is converted to
Code:
<ul class="slidelist">
  <li></li>
  <li class="last"></li>
</ul>

And http://docs.jquery.com/Attributes/attr"

What are you trying to accomplish/change/fix?
 
Last edited by a moderator:
  • #3
I am just trying to understand the code to provide different aspects to my webpage. Also sometimes my codes do different things/have different looks on IE and mozilla- so it's nice to know what I'm doing.

Thanks a lot for your help, it really explained a lot.
 

1. What is XHTML Slide Show?

XHTML Slide Show is a type of web presentation that allows for the display of multiple slides or images in a sequential manner. It is created using XHTML, a markup language for creating web pages, and can be enhanced with the use of Javascript and jQuery.

2. What is the role of Javascript and jQuery in an XHTML Slide Show?

Javascript and jQuery are used to add interactivity and dynamic effects to an XHTML Slide Show. They can be used to create animations, transitions, and other visual effects, as well as control the navigation and functionality of the slide show.

3. How do you create an XHTML Slide Show?

An XHTML Slide Show can be created by first designing the layout and structure of the slides using XHTML markup. Then, Javascript and jQuery can be added to add interactivity and functionality to the slide show. Finally, CSS can be used to style the slides and give the presentation a cohesive look and feel.

4. Can I customize the appearance of an XHTML Slide Show?

Yes, the appearance of an XHTML Slide Show can be customized using CSS. This includes changing the font, color, and size of the text, as well as the background, borders, and other visual elements.

5. Is it necessary to have a strong understanding of XHTML, Javascript, and jQuery to create an XHTML Slide Show?

Yes, a strong understanding of XHTML, Javascript, and jQuery is necessary in order to create an XHTML Slide Show. Without this knowledge, it will be difficult to design and add interactivity to the slide show. It is recommended to have a basic understanding of these languages before attempting to create an XHTML Slide Show.

Similar threads

  • Programming and Computer Science
Replies
2
Views
5K
Back
Top