Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Created July 8, 2015 23:31
Show Gist options
  • Save adamsilverstein/09485db84e41f27eaf13 to your computer and use it in GitHub Desktop.
Save adamsilverstein/09485db84e41f27eaf13 to your computer and use it in GitHub Desktop.
function set_attribute( element, setFrom, setTo ) {
var val = element.val();
from = 'type=\"' + setFrom + '\"',
to = 'type=\"' + setTo + '\"';
// Workaround for element.attr('type', 'password'); doesn't work in ie8
element
.replaceWith(
element = $( element.wrap( '<label></label>' )
.parent('label')
.html()
.replace( from, to )
)
.val(
element.data( 'pw' )
)
)
.unwrap( 'label' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment