0

I want to add an "info div" on a website. For this, I add some html via a Tampermonkey script:

// ==UserScript== 
// @name         New script 
// @namespace    http://tampermonkey.net/ 
// @version      1.1 
// @description  try to take over the world! 
// @author       You 
// @match        http://www.monsite.com/* 
// @grant        GM_getValue 
// @grant        GM_setValue 
// @grant        GM_listValues 
// @grant        GM_addStyle 
// @grant        GM_getResourceText 
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js
// @require      https://code.jquery.com/ui/1.11.4/jquery-ui.min.js
// ==/UserScript== 
/* jshint -W097 */ 
'use strict'; 

var html = "<div id='myDiv'>CONTENT</div>"; 
$('body').append(html);

$(function() {
    $( "#myDiv" ).draggable();
});

When I try to move it, I got a console error :

Uncaught TypeError: n.style is not a function

For information, I got the same issue if I want to use $.slideToggle()..

Any idea how to fix this ?

Thanks

Mr Jenkins
  • 27
  • 6

1 Answers1

0

I would try this:

$(function() {
    var $html = $("<div id='myDiv'>CONTENT</div>"); 
    $html.draggable();
    $('body').append($html);
});

Also check the Scripts that are running on the site. They may interfere with your code or vice-versa if they are running JQuery already.

Twisty
  • 30,304
  • 2
  • 26
  • 45