jquery 替换img 属性

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <meta http-equiv="X-UA-Compatible" content="IE=edge">
 6     <title></title>
 7     <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
 8 </head>
 9 <style>
10   #btnTex{width:80px; height:50px; margin: 10px;}
11   
12 </style>
13 <body>
14   <input type="text" id="inputTex"/> 
15     <button type="text" id="btnTex">按钮</button>
16   <img id="imgTex" src="image/Selected.png"/>
17     <div id="divRed"></div>
18     <script  type="text/javascript" charset="utf-8">
19        $(function(){
20               var inputTex = $('#inputTex');
21               var btnTex = $('#btnTex');
22               var imgTex = $('#imgTex');
23                btnTex.click(function(){
24                 imgTex.attr('src',inputTex.val());
25 
26               })
27             
28         
29           
30              
31        })
32    </script>  
33 </body>
34 </html>

 

posted @ 2016-12-22 10:27  deveil  阅读(607)  评论(0编辑  收藏  举报