Adsense
Popular Posts
- Code update from PHP 7.4 to PHP 8.1 - PhpSpreadsheet
- MySQL workbench -"Could not decrypt password cache"
- Code update from PHP 7.4 to PHP 8.1 - Worksheet/Iterator.php
- Rendering HTML tags inside textarea
- axios handle blob type data
- Unix Utils and wget in Windows
- increase mysql query speed
- Setup vi syntax for PHP
- Get WAMP running on EC2
- add comment to table columns in phpMyAdmin
Tuesday, June 16, 2015
Pass data via attribute in JavaScript
We create a data attribute sid (you can change to any name) and assign it value 3456
<tr><td class='sid' id='firstname' data-sid='3456'></td> </tr>
Below is the script to click this cell to display this value using jQuery:
$('.sid').on('click', function(){
var $tr = $(this).parents('tr');
var sid = $tr.find('#firstname').attr('data-sid');
alert(sid);
});
Labels:
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment