Wikipedia:User scripts/Guide: Difference between revisions

Content deleted Content added
Zvn (talk | contribs)
Line 271:
 
2) using DOM methods: <tt>'''createElement()'''</tt>, then attach as child using <tt>'''appendChild()'''</tt> or <tt>'''insertBefore()'''</tt>. For examples of usage see the code of <tt>addPortletLink()</tt>
 
=== Removing elements ===
 
To move an element simply attach it in another place with <tt>appendChild()</tt> or <tt>insertBefore()</tt>.
 
To hide an element you can set its <code>style.display</code> to <code>none</code>:
 
<source lang="javascript">
//Example: remove copyright warning from edit page
var el = document.getElementById('editpage-copywarn');
if (el) el.style.display = 'none';
</source>
 
This is easier with [[Special:Mypage/monobook.css|your monobook.css]] though: <code style="white-space:nowrap">#editpage-copywarn {display:none}</code>
 
== Edit page ==