|
|||
Script verursacht einen Fehler
Hi, ich habe mir ein Script aus dem Internet besorgt und es verursacht einen Fehler, den ich gern behoben hätte.
Zitat:
Edit fiddle - JSFiddle HTML-Code:
<script> /* <![CDATA[ */ (function($) { $.fn.replaceTagName = function(replaceWith) { var tags = [], i = this.length; while (i--) { var newElement = document.createElement(replaceWith), thisi = this[i], thisia = thisi.attributes; for (var a = thisia.length - 1; a >= 0; a--) { var attrib = thisia[a]; newElement.setAttribute(attrib.name, attrib.value); }; newElement.innerHTML = thisi.innerHTML; $(thisi).after(newElement).remove(); tags[i - 1] = newElement; } return $(tags); }; })(window.jQuery); $('b').replaceTagName('strong'); $('i').replaceTagName('em'); $('u').attr('class','underline' ); $('u').replaceTagName('span'); // replace all u´s with span´s $('nobr').attr('class','nobr' ); $('nobr').replaceTagName('span'); /* ]]> */ </script> Ersetze newElement.setAttribute(attrib.name, attrib.value); durch $(newElement).attr(attrib.name, attrib.value ); HTML-Code:
<script> /* <![CDATA[ */ $(document).ready(function() { (function ( $ ) { $.fn.replaceTagName = function( options ) { var tags = [], i = this.length; while (i--) { var newElement = document.createElement(options), thisi = this[i], thisia = thisi.attributes; for (var a = thisia.length - 1; a >= 0; a--) { var attrib = thisia[a]; $(newElement).attr(attrib.name, attrib.value ); }; newElement.innerHTML = thisi.innerHTML; $(thisi).after(newElement).remove(); tags[i - 1] = newElement; } // return $(tags); }; }( jQuery )); $('b').replaceTagName('strong'); $('i').replaceTagName('em'); $('u').attr('class','underline' ); $('u').replaceTagName('span'); // replace all u´s with span´s $('nobr').attr('class','nobr' ); $('nobr').replaceTagName('span'); }); /* ]]> */ </script> Geändert von gabischatz (08.01.2014 um 18:12 Uhr) Grund: Lösung gefunden |
Sponsored Links |
Themen-Optionen | |
Ansicht | |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
Redesign für Steiner Cycling Team | pkipper | Site- und Layoutcheck | 11 | 09.02.2011 13:25 |
Javascript slideshow script - Fehler in Firefox. | trent | Javascript & Ajax | 2 | 22.11.2010 09:45 |
PHP Script mit GET-Parametern als Img-Src | Ares | Serveradministration und serverseitige Scripte | 2 | 13.09.2008 22:19 |
PHP: ereg_replace verursacht fehler nach Umstellung auf UTF-8 | braindead | Serveradministration und serverseitige Scripte | 5 | 02.07.2007 11:28 |
Fehler bei HTTPRequest über POST | psycho_dmr | Javascript & Ajax | 0 | 12.04.2007 17:16 |