swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.25k stars 744 forks source link

Allow the selector receive an Element or JQueryNode #748

Open brunoinds opened 3 years ago

brunoinds commented 3 years ago

Many developers creates elements programatically. Reference the selector by it's own path is not good in this case. So, the selector property could receive the element itself instead only receive the path string.

const element = document.createElement('button');
el.innerHTML('Click Me')

$.contextMenu({
    // Allow the selector be an Element or JQueryNode Element
    selector: element // or $(element), to make it easy for the implementation with JQuery
})

document.body.appendChild(element)