I try to add the librar" /> I try to add the librar" /> I try to add the librar"/>

Create highslide clicks events in jQuery(document).ready

234 Views Asked by At

I have the following html code for

<td><a href="url_to_large_image" class="myClass"><img alt="" src="url to trumb" /></a></td>

I try to add the library highslide.Js

jQuery(document).ready(function() {
    $('.myClass a').each(function() {
        $(this).click(function() {
            my res = hs.expand(this);
            alert(res); // false
            return false;
        });
    });
});

When i click on the link the browser reloads the page and shows url_to_large_image, although the method returned false !!

But! If the page already has a following links for highslide, it all works

<td><a href="url_to_large_image1" class="myClass"><img alt="" src="url_to_trumb1" /></a></td>
<td><a href="url_to_large_image2" "return hs.expand(this)"><img alt="" src="url_to_trumb2" /></a></td>

In this case, click the url_to_large_image1 open highslide's popup...

How to solve a problem? Thank you in advance

2

There are 2 best solutions below

1
optimisticupdate On

I guess it's a problem with your selector

$('.myClass a')

will select all a-tags inside of myClass.

Try to use .myClass only to select your a-tags.

jQuery(document).ready(function() {
$('.myClass').each(function() {
    $(this).click(function() {
        my res = hs.expand(this);
        alert(res); // false
        return false;
    });
});
});
0
Muhammad Amjad On

You need to return the object rather then returning a false.

Try the code below

return hs.expand(this);