Adsense
Popular Posts
- Install APXS in Redhat Linux
- MySQL workbench -"Could not decrypt password cache"
- Transfer modules between sites
- JavaScript, remove trailing insignificant zeros after toFixed function
- Set Windows path command line
- datatable order by nunmeric
- MySQL date created and date modified
- super(props) in React
- PHP, dump varailbes in a format way
- React: connect(mapStateToProps, mapDispatchToProps)
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