I would like to change an attribute of a dynamic element with jquery

3

I have the following code that I thought would work, but nothing happens ...

$(document).on('click', '#tab-departamentos a', function(){
  $('textarea').each(function(){
    var a = (this.scrollHeight-12)/20;

    //alert(a);

    $(this).attr('rows', a);
  })

  var href = $(this).attr('href');
  $(href).tab('show');
})

I did not post the fiddle because the code is small so I did not see any need.

This link here (# tab-departments a) serves to show the contents of a Bootstrap Tab (getbootstrap.com/javascript/#tabs) like ($ (href) .tab ('show')), which I can only edit the rows attribute of the main Tab, the others that are hidden and are dynamic elements are not changed ...

    
asked by anonymous 06.02.2015 / 15:52

1 answer

0

I tested it here and it seems to be working ...

$(document.body).on('click', '#tab-departamentos a', function () {
        $('textarea').each(function () {
            var a = (this.scrollHeight - 12) / 20;
            alert(a);
            $(this).attr('rows', a);
        });

        var href = $(this).attr('href');
        //$(href).tab('show');
        alert(href);
    });

Or what exactly was the part that did not work? Have you experienced any errors on the console?

I just did not test the panel, the rest is apparently working ..

    
06.02.2015 / 15:56