jQuery addClass example

Change class name on click in jQuery

by mamounothman

HTML

<html>
<script src="//bossanova.uk/jexcel/v4/jexcel.js"></script>
<script src="//bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="//bossanova.uk/jexcel/v4/jexcel.css" type="text/css" />
<link rel="stylesheet" href="//bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>
<div>
    <button onclick="$('#log').html('')">Clear</button><br>
    <p>Log:</p>
    <div id="log" style="background-color:#c7eaff; border-radius:2px; color:#000; padding:20px"></div>
</div>

<script>
var changed = function(instance, cell, x, y, value) {
    var cellName = jexcel.getColumnNameFromId([x,y]);
    $('#log').append('<p>New change on cell ' + cellName + ' to: ' + value + '</p>');
}

var data = [
    ['Mazda', 2001, 2000, '2006-01-01'],
    ['Pegeout', 2010, 5000, '2005-01-01'],
    ['Honda Fit', 2009, 3000, '2004-01-01'],
    ['Honda CRV', 2010, 6000, '2003-01-01'],
];

jexcel(document.getElementById('spreadsheet'), {
    data:data,
    rowResize:true,
    columnDrag:true,
    columns: [
        { type: 'text', width:'200' },
        { type: 'text', width:'100' },
        { type: 'text', width:'100' },
        { type: 'calendar', width:'100' },
    ],
    onchange: changed
});
</script>
</html>