IE issue with custom jQuery extender
My code works with the newest versions of Chrome and Firefox, but doesn't work with IE9,( I don't have earlier versions to test yet).
Here is my jQuery extender
(function ($) {
$.fn.myModal = function() {
var offsetx = this.width() / 2;
var offsety = this.height() / 2;
var bg = $("<div id='modal-overlay'></div>");
$("body").append(bg);
//etc.....
}
}) ( jQuery );
I used a try/catch block to开发者_开发问答 determine which lines of code is throwing an error and it appears that any reference to this
is the problem. Even if I wrap this
with $(this)
it still doesn't work.
Btw I'm calling this extender like so:
$(function ()
{
$("#login").click(function ()
{
$("#login-modal").myModal();
});
});
For what it's worth all of this code is in an external file which gets called in the head
of the document.
精彩评论