mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
20 lines
811 B
JavaScript
20 lines
811 B
JavaScript
//add class .selected to specified element
|
|
function select(elementId) {
|
|
//console.log(arguments.callee.caller.name, 'selected ', elementId);
|
|
var element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
|
element.classList.add('selected');
|
|
}
|
|
|
|
//remove .selected class from specified element
|
|
function deselect(elementId) {
|
|
//console.log('deselected ', elementId);
|
|
var element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
|
element.classList.remove('selected');
|
|
}
|
|
|
|
//toggle the status of the .selected class on the specified element
|
|
function toggle(elementId) {
|
|
//console.log('toggled ', elementId);
|
|
var element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId);
|
|
element.classList.toggle('selected');
|
|
} |