jQuery Selecting HTML Elements

To Read Select Option Value

$('#selectId').val();

To Set Select Option Value

$('#selectId').val('newValue');

To Read Selected Text

$('#selectId>option:selected').text();

changes the src and alt attributes for an <img> element. The code $('img') is selecting the <img> element.

<!DOCTYPE HTML>
<html>
<head>
<title>jquery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('img').attr({src: 'images/image.jpg', alt: 'image'});
});
</script>
</head>
<body>
<strong>This is image.</strong>
<img src="images/image.jpg" alt="cover1" />
</body>
</html>
Submit an Idea
  Thank you for your valuable feedback.
Your E-mail (optional):
Select Option:
Description:
 
Feedback
Your Name / email address
Feedback as
Your feedback
close
Quickly sign in with:

Create a FATALWEB account here:

First name:

Last name:

E-mail address:

Join Fatalweb

Already have a fatalweb account? Log in here