javascript - web - copy section to clipboard and remove certain elements -
ive got method copy section of html clipboard allow pasting elsewhere. table of main content pasted excel , keep formatting, lovely.
what want remove elements section. main ones checkboxes , textboxes - cause excel go screwy, , reason cannot delete them excel - have start new sheet.
this method using copy:
$('#copyclipboard').click(function () { var contentdiv = document.getelementbyid('copyablecontent'); var holdtext = document.getelementbyid('holdtext'); holdtext.innertext = contentdiv.innerhtml; copied = holdtext.createtextrange(); copied.execcommand('copy'); alert('data copied clipboard!'); }); (excuse horrible mix of jquery , javascript).
so have 'contentdiv' variable, want parse , remove inputs, , possibly other elements (i give them css class 'donotcopy' or something).
how can this?
you can use:
contentdiv.innerhtml.replace(/<input[^>]*>/g,"") check replace method here: http://www.w3schools.com/jsref/jsref_replace.asp
you may have adjust regex needs
Comments
Post a Comment