I need to write an if statement based on whether or not an href contains a text link or an image link. So if I get the content of the link like this :
jQuery(document).ready(function($){
$('a').click(function(event) {
var $linkContent = $(this).html();
// this doesnt work.. just one of the things I tried
// var imgsrc = $(this).attr('src');
});
})
I also thought I could go the other way and just get the text content like :
var linkContent = $(this).text();
Then when I alert this variable it shows text for text links and is blank for images. Great! But still isnt working for me. I was going to write rules based on its .length but if I alert the lengths the image links are still giving me an integer even though if alert the .text() it is blank. I am confused!
thisin your click handler will always be an anchor element because it’s attached to the anchor elements in your code. however just do