Question

I am very new to jquery plugin and widgets, was just trying out a simple plugin, in which for the div I am trying to append a new div, but it's not able to attach and there are no errors, I am not able to figure out what is the mistake I have done.. The widget code goes below,`(function ($) {

jQuery.widget("ui.test", {
    options: {},
    _create: function () {
            this.element.append("<div>da</div>")
    },
    _destroy: function () { },
    _setOption: function (key, value) { }
});

}(jQuery));`

In the html I have a div with id="test" and it'been called like this,

$("test").test();
Was it helpful?

Solution

Your selector is wrong, in order to use id selector you need # + id, ex #test will select the element with id test

$("#test").test();

Demo: Fiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top