diff --git a/js/jquery.mobile.degradeInputs.js b/js/jquery.mobile.degradeInputs.js index 8f4a0245..aeec2c43 100644 --- a/js/jquery.mobile.degradeInputs.js +++ b/js/jquery.mobile.degradeInputs.js @@ -39,10 +39,13 @@ $( document ).bind( "pagecreate enhance", function( e ){ optType = o.degradeInputs[ type ] || "text"; if ( o.degradeInputs[ type ] ) { - $this.replaceWith( - $( "
" ).html( $this.clone() ).html() - .replace( /\s+type=["']?\w+['"]?/, " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\" " ) - ); + var html = $( "
" ).html( $this.clone() ).html(), + // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead + hasType = html.indexOf( " type=" ) > -1, + findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/, + repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" ); + + $this.replaceWith( html.replace( findstr, repstr ) ); } });