$(this + "option:selected").attr("rel") option selected is not working in IE
The code below works perfect in Firefox, not in IE8 :(
any fix is appreciated!
- <script language="javascript" type="text/javascript">
$(document).ready(function(){
//var imgpath = 'images/sandles/';
$("select.swatchesList").bind('change', function(event){
var img = $(this + "option:selected").attr("rel");
$('#HeroImage').attr('src' , img);
});
//Key Board event
$("select.swatchesList").keypress(function(){
var img = $(this + "option:selected").attr("rel");
$('#HeroImage').attr('src' , img);
});
});
</script>
HTML
================
<div id="HeroContainer">
<img src="abc.png" id="HeroImage" alt="Hero" width="265" height="265" />
</div>
<select class="swatchesList" name="swatches">
<option value="" selected="selected">Select a Color</option>
<option rel="abc.png" value="red">Red</option>
<option rel="xyz.png" value="black">Black</option>
<option rel="123.png" value="yellow">Yellow</option>
</select>
Gopi