我是新來的使用Greasemonkey和jQuery,我需要添加一個設置面板到當前頁面,當圖像被點擊。創建一個div,並通過Greasemonkey和jQuery將其添加到頁面
有人能給我一個如何通過jQuery創建div的例子,然後將其添加到當前頁面,絕對定位在其他元素?
下面是我正在使用的一些測試代碼,有點盲目地涉及到的方法。
var settingsDiv = '<div style="position:absolute;bottom:0;width:500px;padding:0;" id="kwdHelpInfo">This is the div that I want to add to the page</div>';
//the #kwdHelp element is an image file already in the document. When its clicked, I want to show the settingsDiv...
jQuery('#kwdHelp').live('click',function(){
//alert('clicked show help');
//var newcell = jQuery(settingsDiv);
//jQuery(newcell).show();
});
+1夠簡單。謝謝! – RegEdit
很高興我能幫到你。 :) – 65Fbef05