Better way to find Class in event.target parentnodes using jquery and javascript?
- by Cama
Currently, I check the target of the input box keyup event to see if it is contained within a div wit class "editorRow" using:
var $parentClass = event.target.parentNode.parentNode.parentNode.className;
Is there a better way to do this in case extra markup is added between the div and the span tags?
<div class="editorRow">
<li>
<span class="wi1">
<input type="text" value="" style="width: 80px;" name="LineItems9" id="LineItems_9">
</span>
</li>
</div>
$("input").live("keyup", function(event) {
return GiveDynamicFieldsLife(event);
});
function GiveDynamicFieldsLife(event) {
**var $parentClass = event.target.parentNode.parentNode.parentNode.className;**
if ($parentClass == "editorRow") {
//Do Stuff
}
}