admin管理员组文章数量:1400095
Can anyone please guide me regarding how can I add custom javascript in Laravel project?
I did google and found some steps but unable to figure out what the error is going on?
Steps I
- Created a custom.js in my public folder with a simple function
- add script tag in my
app.blade.php
- extends my layout
But the function is not working
$(document).ready(function()
{
alert("hello this is test");
})
custom.js
enter code here
<script type="text/javascrip" src=".4.1/jquery.min.js"></script>"
<script type="text/javascript" src="{{asset('js/custom.js')}}"></script>
code I added in my main file app.blade
but when load my page it doesn't give me an alert. Alert is just for testing I tried with various function.
Can anyone please guide me regarding how can I add custom javascript in Laravel project?
I did google and found some steps but unable to figure out what the error is going on?
Steps I
- Created a custom.js in my public folder with a simple function
- add script tag in my
app.blade.php
- extends my layout
But the function is not working
$(document).ready(function()
{
alert("hello this is test");
})
custom.js
enter code here
<script type="text/javascrip" src="https://ajax.googleapis./ajax/libs/jquery/3.4.1/jquery.min.js"></script>"
<script type="text/javascript" src="{{asset('js/custom.js')}}"></script>
code I added in my main file app.blade
but when load my page it doesn't give me an alert. Alert is just for testing I tried with various function.
Share Improve this question edited Sep 24, 2019 at 11:16 Udhav Sarvaiya 10.1k13 gold badges60 silver badges67 bronze badges asked Sep 24, 2019 at 10:39 Samir ParuthiSamir Paruthi 1211 gold badge3 silver badges14 bronze badges 4- Have you tried viewing the source code from the web browser? – Chuksy Commented Sep 24, 2019 at 10:41
- First of all thanks chusky for showing interest but yes I did and its showing but nothing working and one more thing If I am making a simple function without $document.ready like function check(){alert("example") and call it via on click function its working but when i use it by $(document).ready(function(){}) its not working – Samir Paruthi Commented Sep 24, 2019 at 10:43
- 1 @SamirParuthi Hello, Can you check your browser console? If any error occurred. please shared with us. – Amit Senjaliya Commented Sep 24, 2019 at 10:48
- What error are you getting? – Dilip Hirapara Commented Sep 24, 2019 at 10:52
2 Answers
Reset to default 3- You misspelled javascript
- Remove the (") after writing the
</script>
For Javascript:
<script src="https://ajax.googleapis./ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="{{ URL::asset('js/custom.js') }}"></script>
Make your directory structure is like this for JS: /public/js/custom.js
I have to review your code. I have found an error in your code like a spelling mistake.
<script type="text/javascript"
src="https://ajax.googleapis./ajax/libs/jquery/3.4.1/jquery.min.js"></script>"
You have miss t
at the end of javascript
.
本文标签: phpHow Can I add Custom javascript file in my laravel projectStack Overflow
版权声明:本文标题:php - How Can I add Custom javascript file in my laravel project? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744233176a2596435.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论