Fau*_*Law 4 javascript jquery laravel
jQuery的
<script src="http://localhost/project/public/plugins/jQuery/jquery-2.2.3.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
我的代码
<script type="text/javascript">
function readURL(input){
if(input.files && input.files[0]){
var reader = new FileReader();
reader.onload=function(e){
$('#showimages').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#inputimages").change(function(){
readURL(this);
});
</script>
<img src="" id="showimages">
<input type="file" name="images" id="inputimages">
Run Code Online (Sandbox Code Playgroud)
我得到这个错误
未被捕获的ReferenceError:在http:// localhost / project / public / user / 1 / edit:308:9中未定义$
*第308行-> $("#inputimages").change(function(){
我在js和jquery中是新手,请帮助我解决此错误...
我在该部分之外编写了脚本。这就是为什么发生错误,请参阅我的答案。
谢谢大家!
此错误已解决,我必须在.blade.php laravel中编写
@section('script')
<script type="text/javascript">
//my code here
</script>
@endsection
Run Code Online (Sandbox Code Playgroud)