I have several div elements. On the mousedown event I am getting the elements attribute that I clicked on and then using Jquery offset method,
I can't seem to trigger the $(elt)
properly, so that it picks up as Jquery.
I am trying to use as least as possible of Jquery library as wan to get rid of it.
offsetLeft and offsetTop are both JavaScript properties that are defined on an HTML element. offset() is a jQuery method that requires a jQuery object.
I understood that all you need to is wrap the element like so $(elt)
.
I get error on the last line on JS before closing tag.
elementBlock.on('mousedown',function(e){
var el = e.target.nodeName;
var elt = e.target.getAttribute('id');
console.log(elt); // i get the clean attribute
console.log(el); // i get DIV
elt.tmp.left = e.clientX - $(elt).offset().left;
}
HTML
<div id="elementBlock">
<div id="blue-left"></div>
<div id="blue-right"></div>
</div>