我们在选择相册的时候需要得到图片的文件名以做数据使用,下面使用jquery来演示相册的图片选择然后得到文件名
<script src="/js/jqmin.js"></script> <script type="text/javascript"> $(function(){ $(".ttjepg").click( function(){ var srwbk=$(this).attr("title");//获取选中的img 的titile值 //alert(srwbk); $('#srdd').val(srwbk);//输出到指定输入框 $('.ttjepg').css("border","");//将border属性清空 $(this).css("border","1px solid red");//增加border的外框为红色的属性 }); }); </script> <input type="text" name="" id="srdd"> <div style="width:460px; height:230px;overflow:auto;"> <img src='\file\1.jpg' style='max-width:100px; max-height:100px;margin:3px;' class='ttjepg' title='1.jpg'> <img src='\file\2.jpg' style='max-width:100px; max-height:100px;margin:3px;' class='ttjepg' title='2.jpg'> <img src='\file\3.jpg' style='max-width:100px; max-height:100px;margin:3px;' class='ttjepg' title='3.jpg'> </div>