jQuery click event on radio button

<!DOCTYPE html>
<html>
<head>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script&gt;
<script>
$(document).ready(function(){
$(“.radio”).click(function(){
var id=$(this).attr(‘id’);
$(‘.dd’).hide();
$(‘#d’+id).show();

});
});
</script>
</head>
<body>

<input type=”radio” name=”test” class=”radio” id=”textbox”>url<br/>
<input type=”radio” name=”test” class=”radio” id=”fileupload”>uplaod

<div id=”dtextbox” style=”display:none” class=”dd”>
<input type=”text” name=”url”>
</div>

<div id=”dfileupload” style=”display:none” class=”dd”>
<input type=”file” name=”img”>
</div>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s