Append <a href> with some string and "alt" of the child image
I have been trying to accomplish something.
For every a tag enclosing an images,
I am trying to append some strings along with the 'alt' attribute of the image to the end of <a> tag's href attribute based on the condition that,
if a:contains('?') then it will appended with "&text"
else , append with "?text"
my script goes like this,
<script>
$(document).ready(function() {
$(document).ready(function() {
$('a').each(function() {
var baoBao = $('a').children('img').attr('alt');
var noQ = '?text' + baoBao;
var yesQ = '&text' + baoBao;
if('a:not(:contains("?")')
{
this.href += noQ;
}
else {
this.href += yesQ;
}
});
});
});
</script>
Presently it does not work,
Can some one please help me.