5 Comments

  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hey Raphaël Péguet,

     

    Can be done something like this:

    $('#request_subject').val('Product Registration').css("color","red");
     $('#request_subject').click(function(){
        $(this).val('Product Registration').css("opacity"," .5");
     });


    Output:
    Default



    After clicking:



     

    Team

    0
  • Raphaël Péguet - Officers.fr

    Ifra Saqlain Thank you very much Ifra! 

    It works but because of "onclick" function if I write over the "native" text 

    Then go to another field and come back to the previous field to rewrite "the on click function" will erase what I wrote.

    I did a video about it: https://www.loom.com/share/5e5d95df2e2a499787a756d44298126a

    So maybe we should ask a "if" to the "onclick" to say if val = native value then fade if not don't do anything.

    Best regards, 

    Raphaël

     

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    @Raphaël Péguet, try this updated code and remove previous:

        var textOpacity = document.getElementById("request_subject");
        var fieldValue = document.getElementById("request_subject").value = 'CUSTOM TEXT';
        textOpacity.style.color = "red";
      
    window.addEventListener('click', function(e) {   
      if (document.getElementById('request_subject').contains(e.target)){
        textOpacity.style.opacity = "0.5";
      } else{
        textOpacity.style.opacity = "1"
      }
    });

     

    Team

    1
  • Raphaël Péguet - Officers.fr

    Thank you very much Ifra Saqlain it works perfectly!!

    Best regards,

    Raphaël

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Great ! :)

    0

Please sign in to leave a comment.

Powered by Zendesk