0

The following code should trigger on change toggle containers that showing resized text to fit into a box.

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://jquery-textfill.github.io/jquery-textfill/jquery.textfill.min.js"></script>

<script>
$(function(){
  $(".clsNumber").textfill();
});
</script>

<script>
$(document).ready(function(){
  $("button").click(function(){
    $(".clsToggle").slideToggle();
  });
});
</script>
</head>

<body>
  <div class="clsToggle">
    <div class="clsNumber" style="width:100px; height:50px; background-color:red;">
      <span>One</span>
    </div>
  </div>
  <div class="clsToggle" style="display:none;">
    <div class="clsNumber" style="width:100px; height:50px; background-color:green;">
      <span>Two</span>
    </div>
  </div>
  <button>click me</button>
</body>

I would like that the resized text will work for both toggle containers.

Any reason why the hidden box (display:none;) ignores the other script (jQuery TextFill)?

1 Answer 1

1

Change the document.ready code with the following

$(document).ready(function(){
  $("button").click(function(){
    $(".clsToggle").slideToggle();
     $(".clsNumber").textfill();
  });
});

Please find the complete code here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.