JQuery - How to use the Every () method to scroll and change all marked mailboxes on page load

I am loading a webpage that has a series of 20+ flags. The page is loaded with data from the database, so some flags will be checked, and the text fields associated with these flags will contain some text. I think I want to do the following: 1) iterate over all chekboxes and find the ones that are checked 2) then change the β€œdisabled” attribute and css properties for each related text area

Each flag has a unique identifier (for example, specA01, specA02, specA03, etc.), and each textarea has a unique but related identifier (for example, specA01summ, specA02summ, specA03summ, etc.)

I have this code that I changed from another line on the same page, but I know that I misunderstand some basic principle here ... maybe it relates to the ".this" line ...

$("input[type=checkbox][checked]").each( function() { var checkBoxId = $(this).attr('id'); $('#' + checkBoxId + 'summ').removeAttr("disabled"); $('#' + checkBoxId + 'summ').css({'background-color' : '#ffffff', 'color' : '#000000', 'border-color' : '#696FA3', 'height' : '10em'}); $('#' + checkBoxId + 'summRequired').css("display", "block"); }); 

Essentially, in this code I try to execute all checked flags, get each of their identifiers in a variable named "checkBoxID", and then change the textarea element with the identifier "#" + checkBoxId + summ '. Any help or advice you can provide is greatly appreciated. Sorry for my blatant ignorance. I am still learning programming and jQuery.

+4
source share
1 answer
 $(":checkbox:checked").each(function(o){ var chkID = $(this).attr("id"); $("#"+chkID+"summ").removeAttr("disabled"); /* ... */ }); 
+5
source

All Articles