jquery get the image of radio button
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type="text/css">
</style>
<script type="text/javascript">//<![CDATA[
$(window).load(function(){
$('.radio').on({
'click': function(){
console.log($(this).val());
var image_url=$(this).val();
$('#my_image').attr('src',image_url);
}
});
});//]]>
</script>
</head>
<body>
<img id="my_image" src="http://i.imgur.com/tL6nW.gif" alt="">
<br>
<input class="radio" name="radio" value="http://i.imgur.com/tL6nW.gif" checked="" type="radio">Image1<br>
<input class="radio" name="radio" value="http://i.imgur.com/BfZ5f.gif" type="radio">image2
</body></html>
Comments
Post a Comment