programming-examples/js/Htmldom/Highlight the bold words of a paragraph, on mouse over a certain link.js

26 lines
778 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
//First create a list of all bold items
var bold_Items;
window.onload = getBold_items();
// Collect all <strong> tags
function getBold_items()
{
bold_Items = document.getElementsByTagName('strong');
}
// iterate all bold tags and change color
function highlight()
{
for (var i=0; i<bold_Items.length; i++)
{
bold_Items[i].style.color = "green";
}
}
// On mouse out highlighted words become black
function return_normal()
{
for (var i=0; i<bold_Items.length; i++)
{
bold_Items[i].style.color = "black";
}
}