Why can\'t I get this to work??
$(\"a\").each(function() {
if ($(this[href$=\"?\"]).length()) {
alert(\"Contains questionmark\");
}
});
>
You could just outright select the elements of interest.
$('a[href*="?"]').each(function() {
alert('Contains question mark');
});
http://jsfiddle.net/mattball/TzUN3/
Note that you were using the attribute-ends-with selector, the above code uses the attribute-contains selector, which is what it sounds like you're actually aiming for.