bxslider-3
bxslider-3 copied to clipboard
Making the captions box a hyperlink
I've set the BX slider to use the captions from the title text.
Is there a way of making the captions hyperlinks?
$(document).ready(function(){ $(".bxslider li").each(function(){ var sLink = $(this).find('a').attr('href'); $(this).find('div').click(function(){ window.location = sLink; }); });
});
I think I'm missing something here, somewhere within that find('div')...
@aarondavies, can you confirm this worked?
Once you've enabled captions in bxslider settings isn't there a div within the li that contains the caption which you can target?
Yea. Might be called, "bx-captions" for instance. The provided code snippet does not trigger a hyperlink overlay of that area/div.
It should attach an onclick to that div. I guess you could always regex the div into a link too like below. Have not tested this though. http://pastebin.com/u6ZR8vd7
Has anyone confirmed if this works?
I used a custom link with JS function in it and this is how I solved it... If someone else faces the same problem...
//Make caption clickable $(document).on('click', '.bx-caption', function(){ var func = $( $(this).parent() ).find('a').attr('onclick'); eval(func); });
Only tested in Chrome..
Any update on this?