Laravel onclick function not working
Laravel onclick function not working
In this session, we will try our hand at solving the "Laravel onclick function not working".
There could be any reason that laravel onclick function not working in your case. Here we provide code snippet on onclick event which helps you to find out the solution for your problem-
Get data-id attribute value using onclick event on button in javascript
<button data-id="5" onclick="followUser(this); return false;">Follow</button> <script> function followUser(e){ var id = e.getAttribute('data-id'); console.log(id); } </script>
This code snippet will help you to get the value of data-id attribute using onclick event on button in javascript.
-
JQuery get data id attribute value on click button
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <button type="button" data-id="5" id="Button">Follow</button> <script> $(document).ready(function(){ $('#Button').on('click', function(){ var value = $(this).attr('data-id'); alert(value); console.log(value); }); }); </script>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to get only time from created_at in laravel
- Laravel create multiple records in Pivot table
- How to add foreign key in laravel using migration
- How to add active class to menu item in laravel
- How to pass variable from controller to model in Laravel
- Conditional where clause in Laravel
- Laravel route redirect not working
- Route group with URI prefix using middleware and route name prefixes
- First and last item of the array using foreach iteration in laravel blade
- Ajax GET request in laravel
- How to create static page in Laravel
- SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
- Trying to get property 'title' of non-object
- Link storage folder in laravel 8
- How to get session in blade Laravel ?
- How to insert multiple rows in mysql using loop in laravel?
- Insert dummy data in users table Laravel
- Laravel order by date not working
- Laravel URL validation not working
- Insert Comma Separated Values in laravel
- Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
- SQLSTATE[42000]: Syntax error or access violation: 1055
- Composer\Exception\NoSslException
- Laravel get single row by id
- If condition in foreach loop in laravel