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
- Datetime field in Laravel migration
- Remove array keys and values if it does not exist in other array in Laravel
- Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
- Composer create project laravel/laravel example app
- Get domain name in laravel
- Send id with route Laravel
- How to add class to tr in table using foreach in laravel
- Laravel 5.4 save data to database
- Print query in laravel
- How to create event and listener in laravel ?
- Laravel order by date not working
- Create a record if not exist in laravel
- How to run a specific seeder class in laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- Validation errors for multiple forms on same page Laravel
- Laravel 9 pagination with search filter
- Route prefix with auth middleware in laravel
- Display message with session flash using bootstrap alert class in laravel
- How to change default timestamp fields name in Laravel
- Save or update pivot table data with additional column in Laravel
- How to get path from current URL in Laravel
- How to send ID to another page in Laravel
- Recursive function example code PHP Laravel
- Laravel get single row by id
- Insert Comma Separated Values in laravel