A label can be used with break and continue statement to control the flow more precisely.
Example of label in javascript. This example uses the for attribute with each label tag used in the form. In JavaScript ECMA hasnt specified goto statement like in other programming languages so you have to use labels along with break or continue statement. Try it Yourself.
Break can be used with any labeled statement and continue can be used with looping labeled statements. To see how it works simply hit. Set the id attribute inside the element and specify its name for the for attribute inside the tag.
Var x documentgetElementByIdmySelectselectedIndex. Fetch me 10000 Click Here. JavaScript label is unique name as an identifier for a statement.
Label with for loop to break. HTML Code JavaScript label statement. JavaScript label mainly use with break andor continue statement.
A label is simply an identifier followed by a colon that is applied to a statement or a block of code. It is actually far easier to add an id to the label in the form itself for example. Example of the HTML tag with an element inside.
For cases where the data element is inside the label like in this example. In this example we will define two labels by the name innerloop and outerloop which is used with for loop to break the execution of the loop for a specified condition. This JavaScript finds the label for a form element which is helpful for dynamically highlighting or changing a label based on user input.