You are viewing limited content. For full access, please sign in.

Question

Question

.rows textarea object method unavailable in Forms?

asked on December 6

I found a method I want to use on W3Schools to programmatically set the rows of a textarea.

https://www.w3schools.com/jsref/prop_textarea_rows.asp

I verified that forms is using a textarea with a rows property.

<textarea id="Field50" name="Field50" aria-labelledby="Field50" class="cf-xlarge" required="True" rows="4" vo="e"></textarea>

So I tried to use this in forms

  $('.textbox textarea').on('change', function() {
    try{
               alert('I am about to change the rows!');
               $(this).rows = "1";
        }catch(err){alert(err.message)}
    
  });

It does not seem to be accepted in Forms, the rows is hard set to 4.

0 0

Answer

SELECTED ANSWER
replied on December 6

Hey,

You were pretty close. Try this.

$(document).ready(function() {
  $('.textbox textarea').on('change', function() {
    try{
			   alert('I am about to change the rows!');
               $(this).attr('rows', '1');
        }catch(err){alert(err.message);}
    
  });
});

Hope that helps :)

0 0
replied on December 7

That helps a lot, thanks! I looked up attributes vs properties, I guess attributes is what you use when working with HTML and properties are for windows apps with javascript.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.