1
<img src="purplemoon.png" alt="Purple moon" id="moon-photo" />   
<table>
  <tr>
    <th colspan="4">Control panel</th>
  </tr>
  <tr>
    <td>
      <!-- trying to take value from that input -->
      <input type="number" min="0" max="50" class="br-left" />
    </td>
  </tr>
</table>

<script>
    $(document).ready(function(){   
        $('.br-left').on("change",function(){
        $('#moon-photo').css('border-top-left-radius',$('.br-left').val());
    });
});
</script>

I'm trying to take the value from that input number and put border-radius on top left but it's not working.

1 Answer 1

1

Remember about units.

Note: You don't have to select the input element again inside the css function, use this keyword instead.

$(document).ready(function() {
  $('.br-left').on("change", function() {
    $('#moon-photo').css('border-top-left-radius', $(this).val() + 'px');
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" alt="Purple moon" id="moon-photo" />
<table>
  <tr>
    <th colspan="4">Control panel</th>
  </tr>
  <tr>
    <td>
      <!-- trying to take value from that input -->
      <input type="number" min="0" max="50" class="br-left" />
    </td>
  </tr>
</table>

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

1 Comment

Ohhhhhhh. Thank you so much!

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.