jquery - Working with the body element -
i have page (figure below) div#content centered in body. want right-click in body area, outside of div#content, , read color there. if try
$(document).on("contextmenu", "body", function(el){ bodybackgroundcolor = $(el).css('background-color'); debugger; }); i don't catch interrupt when click in wings.
if try
$(document).on("contextmenu",function(el){ bodybackgroundcolor = $(el).css('background-color'); debugger; }); i catch interrupt el = document, $(el).css('background-color') doesn't work.
how should doing this?
thanks.

i think need background-color applied on element right-clicked. if try this.
el in callback not element event, can element e.target or event.srcelement work
$(document).on("contextmenu",function(e){ bodybackgroundcolor = $(e.target).css('background-color'); alert(bodybackgroundcolor); });
Comments
Post a Comment