0

I don't have access to change the HTML. I'm either wanted to either:

  • change the text in the or

  • Hide that Div via CSS (I know how to do this) and add another div under the to add my own text.

     <div class="login-welcome">

                 <img src=" border="0" class="login-logo" alt="">

             <h2>Password recovery</h2> 
             <div class="info">
                 Please enter your username and we will send a password reset link to your email. If you can't remember what your username is please contact your administrator. If you don't have an email address registered with us you will need to contact your administrator to get your password reset. 
             </div>           
     </div>

     <div class="login-form">
         <form action="/account/forgot" method="post"><input name="__RequestVerificationToken" type="hidden" value="_1">

         <div class="login-field" tabindex="0"> 
             <label for="Username" style="display:none;">Username</label>
             <input class="form-control input-lg" id="Username" name="Username" placeholder="Username" required="true" type="text" value="">
         </div>
         <div class="login-button" tabindex="1">
             <input type="submit" class="btn btn-login btn-lg" id="continue" value=" Continue ">
         </div>

         <div class="login-forgot">
             or <a href="/account/login">Back to login</a>
         </div>
         </form>
     </div>
 </div>

I've tried the following code - but it didn't work.

  
$(document).ready(function(){
if(window.location.pathname == '/account/forgot'){
$( ".info" ).append( $( "<p>Test</p>" ) );
}
});
   

All help is appreciated!

Campbell
  • 67
  • 6
  • class selector starts with a `.` for example: `.login-form` In your example there is no such thing as `forgotPasswordContainer` – vanowm Aug 12 '21 at 05:25
  • Sorry but I'm confused by the meaning of `insert a Div after a Class`. Could you please explain more regarding to context? And with jQuery `append()`, the agrument that it takes is of the `string` type. I don't quite get what you are trying to do – Huy Phạm Aug 12 '21 at 05:27
  • Does this answer your question? [How to replace innerHTML of a div using jQuery?](https://stackoverflow.com/questions/1309452/how-to-replace-innerhtml-of-a-div-using-jquery) – A. Meshu Aug 12 '21 at 05:33
  • @vanowm Class selector thanks. Unfortunately it still doesn't work. And apologies. I've updated the code to show correct class now. – Campbell Aug 12 '21 at 05:44
  • @HuyPhạm I need to change the text "Please enter your username and we will send a password etc..." but I can't figure out how to. I don't have access to he direct HTML. – Campbell Aug 12 '21 at 05:46
  • @A.Meshu I wish it did. But I tried that too and it's also not working. – Campbell Aug 12 '21 at 05:46
  • you still missing the `.` in your class selector. `$(".info")` – vanowm Aug 12 '21 at 06:00
  • @vanowm even with the `.` it's not working. – Campbell Aug 12 '21 at 07:16
  • I know it is very late , but the problem is in your jQuery , use `jQuery()` instead of `$` , but their is one more issue in your `append` statement it need to be `jQuery( ".info" ).append( "

    Test

    " );`. Thanks
    – Basir khan Jun 27 '22 at 17:54

1 Answers1

1

there is an issue in your JavaScript code , for selecting class you need to add . with class in jquery like $('.myclass').hide() and for selecting id you need to add # with id like $('#myid').hide() and for selecting tag you need to do something that $("div").hide()... this is the basic concept of selecting specific tag , class or id in jQuery

$(document).ready(function(){
if(window.location.pathname == '/account/forgot'){
$( ".info" ).append("<p>Test</p>" );
}
});

the above code will only work on url /account/forgot so for testing you need to open that specific url

Basir khan
  • 168
  • 8