Without seeing the rest of your markup this will be hard to decipher although I am sure that the answer is simple. Can you post the other relevant code? I am going to take a crack at it though. First things first; using 'length' as a variable name is a bad idea because that is also the name of a function.
Let's make sure we have a "bold" class that we can add with the following CSS;
- <style type="text/css">
- .bold {
- font-weight: bold;
- }
- </style>
Next let's set up our jQuery. We need to loop through each label to find out which one has the attribute that we are looking for;
- $(function() {
- $(".buttons").each(function(){ //loop through everything with a class of buttons
- if($(this).attr("id").length > 3){ //check the attribute length - if it is greater than 3...
- $(this).addClass("bold"); //...add the bold class to this label with a class of buttons
- };
- });
And here are our labels;
- <label id="one" class="buttons">One</label><br />
- <label id="three" class="buttons">Three</label><br />
Whew!
if you do not want to use attributes like id you can get the information in the label tags with .html() something like this;
- if($(this).html().length > 3){ //check the content between the tags length - if it is greater than 3...
Without seeing your code I made best guesses on what you tried to do. Hope this helps!