[thelist] jquery clickable slider

Barney Carroll barney.carroll at gmail.com
Sun Jun 5 07:04:32 CDT 2011


Either you're not providing nearly enough information, or I've misunderstood
something fundamental. Usually with "I don't know what I'm doing wrong"
questions the best thing is to provide a URL, either where the actual code
is, or one created by jsfiddle.net.

On 4 June 2011 15:55, DAVOUD TOHIDY <dtohidy at hotmail.com> wrote:
> I would like to add urls to the images of scroller.

I presume you mean you would like to wrap the images in links (<a/>) with
HREF values. Why can't you do this in the HTML? It doesn't sound like
Javascript is necessary from the outset.

I thought having a for loop and array would work which did not.
If you provide us with the array & loop we might be able to tell you why it
isn't working — as long as you can explain what it was trying to do

> window.location.href = "$('a').each('href')";
>                });
> it does return: not found  .../$('a').each('href')

The code above is saying that whenever your slider object is clicked, the
page should be redirected to the URL "$('a').each('href')". The quotes (")
in this mean that it is not to be interpreted as Javascript and instead
delivered as plain text — which I can tell isn't your intention. Taking the
quotes off reveals invalid jQuery code which appears ill thought out.
However when I try to image what you did intend, I come up with something
like this:

$('#slider a').click(function(){
window.location.href = this.href

…but this is utterly pointless since a link click directing towards its HREF
is entirely standard behaviour (which jQuery ScrollTo does not override).
Try removing this code entirely. Is it working now?


More information about the thelist mailing list