JSFiddle - React, Tailwind, and code Playground
by David Thomas
HTML
<input type="text" name="Category_Product_Search" />
<input type="text" name="An_Entirely_Different_Name" />
JavaScript
function elementIs (e){
var target = e.target,
targetTagName = target.tagName.toLowerCase();
switch (targetTagName){
case 'input':
if (target.name === 'Category_Product_Search') {
// do something, it's an input and has the right name
console.log(target);
}
}
}
document.body.addEventListener('focus', elementIs, true);