Graham
Graham

Reputation: 15

Jquery condition to replace title tags

I have been scratching my head trying to get Jquery to conditionally search and replace title tags in a document. Essentially I want Jquery to go through a list of image tags, check if the image tag is a space " " and if so remove the space "". If the title tag is anything else Jquery should leave it alone.

HTM i am not allowed to add code so I put it here http://www.stylishtimes.com/title.txt

So far I can remove every title tag with:$('#galleria img').attr("title", "");

Thanks in Advance for any help.

Upvotes: 1

Views: 1070

Answers (2)

Ken Redler
Ken Redler

Reputation: 23943

Try this:

$('#galleria img[title=" "]').attr('title','');

Upvotes: 2

3rgo
3rgo

Reputation: 3153

Try this :

var title = $('#galleria img').attr("title");
var newtitle = $.trim(title);
$('#galleria img').attr("title", newtitle);

Upvotes: 0

Related Questions