简体   繁体   中英

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?

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM