Jquery to replace <small>

Asked

Viewed 48 times

0

Quick little question I couldn’t find anywhere..

How can I change the text of a small?

I’m trying with the same code I used to swap a text once, I think the problem is in the selectors, but I have tested with all of them and did not roll. I do not have access to HTML and the version of Jq is 1.12.4 JQ:

$(window).on('load', function(){
    $('td[name=Boleto]')
    .find('small')
    .text('Transferência');
});

html:

<label class="card Billet">
   <input type="radio" value="Billet" class="rdoCreditCards" name="CreditCardProvider" id="CreditCardProvider" displayname="Boleto">
   <span>
      <small>Boleto</small>
   </span>
</label>
  • 2

    Got confused this td[name=Boleto] as it does not even have the element <td> in your code.

  • You are selecting an element that does not exist in your question td

  • @Andersoncarloswoss, exact...

  • I traveled.. I will correct.. haha

  • The rest is right then?

  • If you have a tag small within a td with the name Boleto, would look like this: $(window).on('load', function(){&#xA; $('td[name="Boleto"]')&#xA; .find('small')&#xA; .text('Transferência');&#xA;});

  • It’s not a td, it’s a label inside a div

Show 2 more comments

1 answer

1


The method .on() has been added to jQuery since version 1.7. Probably your code is giving the error $(...).on is not a function, since it says it is using version 1.12.4.

In this version you would have to use the method .load():

$(window).load(function(){

And to change the text, your code is almost correct, just change the selector to the div where is the small. For example:

$(window).load(function(){
    $('div')
    .find('small')
    .text('Transferência');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<div>
   <label class="card Billet">
      <input type="radio" value="Billet" class="rdoCreditCards" name="CreditCardProvider" id="CreditCardProvider" displayname="Boleto">
      <span>
         <small>Boleto</small>
      </span>
   </label>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.