javascriptphpjquerywordpresseasy-digital-downloads

Using Jquery to make text readonly but still clickable


Example Code:

jQuery(document).ready(function($) {    

  //Make upload link readonly
  if( $( '#uploads_link' ).length > 0 ) {
    $( '#uploads_link' ).attr( 'readonly', 'readonly' );
  } 
});

I am trying to figure out how to keep the uploads_link URL path that the user see as readonly, but make it "clickable". Right now the user is able to see the url link and copy and paste it, but now I'm trying to figure out how to make the readonly url clickable.

Any suggestions on how to make a attr( 'readonly', 'readonly') tag clickable?


Solution

  • Try this:

    $(document).ready(function () {    
      $('#txt').click(function () {
        console.log('OK');
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <input id="txt" type="text" readonly>