I am trying to get my plugin to recognize the element which it is called from such as:
(function($) {
$('#element').myPlugin({});
})($)
On a different page –
(function($) {
$.fn.myPlugin = function(settings) {
var element = $(this);
$.post('connection.php',{},
function(output) {
element.html(output);
});
}
})($)
But it for some reason is not working.. i am puzzled
HTML page:
<body>
<div id="element">adsf</div>
</body>
I think what’s throwing you off is that this:
Is not the same as this:
So everything was working, but the DOM element didn’t exist yet as you expected it to.