I have a div with an image and a link in it.
Is it possible that on page load, I can somehow find the href of the link and apply that the anchor tag of the image?
try this:
$(document).ready(function(){
$("#theDiv").find("a").attr("href", $('img').attr('src'));
});
$(document).ready(function(){
$("#anchor").attr("href", $('#continue').attr('href'));
});
http://jsfiddle.net/fFgwb/5/
so, you should add classes like .divs
to divs and other classes to anchor links:
$(document).ready(function(){
$(".divs").each(function(){
$(this).find("a").hasClass("anchor").attr("href", $(this).find("a").hasClass("continue").attr('href'))
});
});