hankknight
asked on
jQuery: Remove attribute from tags in var
Using jQuery, how can I remove all longdesc attributes from images within a var?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var stuff='<p><a><img src="image.gif" longdesc="hello" alt="" /></a></p><p><a><img src="image.gif" longdesc="hello" alt="" /></a></p><img src="image.gif" longdesc="hello" alt="" />';
alert( $(stuff).find('img').removeAttr('longdesc').html() );
// Should alert <p><a><img src="image.gif" alt="" /></a></p><p><a><img src="image.gif" alt="" /></a></p><img src="image.gif" alt="" />
});
</script>
</head>
<body>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window