HI WELCOME TO KANSIRIS

jQuery Show Image Preview with Url Entered in Textbox Example

Leave a Comment
Syntax to Show Image Preview with URL in jQuery

Following is the syntax of showing image preview with the url entered in textbox.


<script type="text/javascript">
$(function(){
$('#txtimgurl').change(function () {
$('#imgurlhead').hide();
$('#uimgurl').attr('src', $('#txtimgurl').val())
})
})
</script>

If you want full code to show image preview with the url entered in textbox in jQuery write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Show Image preview with Url entered in textbox</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function(){
$('#txtimgurl').change(function () {
$('#imgurlhead').hide();
$('#uimgurl').attr('src', $('#txtimgurl').val())
})
})
</script>
</head>
<body>
<form id="form1">
<div>
Enter Image Url: <input type="text" id="txtimgurl" style="" />
<hr />
<img id="uimgurl" />
</div>
</form>
</body>
</html>

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.