• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

[FRAGE] Input Auswahl aufheben

Ciatronical

New member
Hey All,

ich habe ein Input und wende select() an.


Das Aufheben der Auswahl klappt nur umständlich mit this.selectionStart = this.selectionEnd = pos;

HTML:
<form><input id='test' value='myDashboardTest'>myInput</input></form>

Code:
$(document).ready(function () {
	$( 'form input:text' ).on( "focus", function() {
    	var pos = this.selectionStart;
     	$( this ).select();
	document.execCommand("copy");
        $( this ).prop("selected", false);
        $( this[0] ).prop("selected", false);
        $( this ).removeAttr("selected");
        //$(this ).blur();  //no focos
	//this.selectionStart = this.selectionEnd = pos;; //IS OK  
        console.log($( this ))
        });
})

JSFiddle
Doch warum klappt das Aufheben mit prop() oder attr() nicht??
Viele Grüße Ronny
 
Zurück
Oben