Hi there, I am in a bit of a situation here trying to prevent the browser from following a link within a <a>
This is the html code:
<a href="#" onclick="changeImage(this,'/folder/images/23.jpg');">
<img src="/folder/images/23_thumb.jpg" alt="">
<span>this is it</span>
<h3>This is it</h3>
<p class="caption">lorem ipsum...</p>
</a>
and here's the script:
function changeImage(calledFrom, big_image){
var newImage = $('#placeholder_image');
var newTitle = $(calledFrom).find('h3').html();
var newText = $(calledFrom).find('p').html();
newImage.fadeOut(50, function(){
newImage.attr('src', big_image);
}).fadeIn(900);
$('.car_model_description')
.find('h3').html(newTitle).end()
.find('p').html(newText);
Cufon.replace('.car_model_description h3');
Cufon.replace('.car_model_description p');
}
function resetThumbnails(){
$('.thumbnails a').each(function(){
$(this).stop(true, true).fadeTo(500,1);
});
}
$(document).ready(function(){
$('.thumbnails')
.mouseleave(function(){
resetThumbnails();
})
.find('a').hover(function(){
hoverThumbnail(this);
});
});
function hoverThumbnail(calledFrom){
var $calledFrom = $(calledFrom);
$('.thumbnails a').each(function(){
if($(this).get(0) == $calledFrom.get(0)){
$(this).fadeTo(0,1);
}
else {
$(this).fadeTo(0,0.5);
}
});
}
Now, to stop the default behaviour I could simply add a return:false; after the javascript call in the html but the problem is that I need the link to be activated if people click on what's on the span tag. The way the script at the moment is that when users click on the thumbnail image the big image will change accordingly but when they click on the text in the span I need that text to be a link and I need the browser to follow that link only in that particular situation. Does it make sense?
I wonder how I can do that. If I add the return:false; the link won't work at all, but I need a way to stop the link from working when they click on the thumbnail and to work when they click on the text.
any idea?is it doable?
thanks