Get image title attribute from an image element in jQuery

Description

The following code shows how to get the title attribute from an image element.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from  w  ww .j ava 2  s.  co  m-->
    document.writeln($("img").attr("title"));

  });
</script>
</head>
<body>
<body>
  <img src="a.gif" title='title of an image' />
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities