কম্পিউটার টিউটোরিয়াল

HTML for অ্যাট্রিবিউট


বিবরণ

HTML for অ্যাট্রিবিউট <label> এলিমেন্টকে প্রথম লেবেলযোগ্য এলিমেন্টের সাথে বাঁধে যেটির id for অ্যাট্রিবিউটের মান के সমান।

সিনট্যাক্স

নিচে সিনট্যাক্স দেওয়া হলো:

১. for অ্যাট্রিবিউটের মান রিটার্ন করা:

labelObject.htmlFor

উদাহরণ

আইয়ে for অ্যাট্রিবিউটের একটি উদাহরণ দেখি:

<!DOCTYPE html> <html> <head> <title>Label htmlFor</title> <style>    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } </style> </head> <body> <form> <fieldset> <legend>Label-htmlFor</legend> <label id="CurrentEditor" for="editorTwo">Current Editor:</label><br> <input type="text" id="editorOne" placeholder="editorOne"> <input type="text" id="editorTwo" placeholder="editorTwo"> <input type="button" onclick="getEventData()" value="Change Editor"> <div id="divDisplay">Label for attribute set as editor two</div> </fieldset> </form> <script>    var divDisplay = document.getElementById("divDisplay");    var labelSelect = document.getElementById("CurrentEditor");    function getEventData() {       if(labelSelect.htmlFor === 'editorTwo'){          divDisplay.textContent = 'Label for attribute set as editor one';          labelSelect.htmlFor = 'editorOne';       }    } </script> </body> </html>

এটি নিচের আউটপুট তৈরি করবে:

১) 'Change Editor' বাটনে ক্লিক করার আগে:

HTML for অ্যাট্রিবিউট

২) 'Change Editor' বাটনে ক্লিক করার পর:

HTML for অ্যাট্রিবিউট

  1. HTML rowspan অ্যাট্রিবিউট

  2. HTML tabindex অ্যাট্রিবিউট

  3. HTML required অ্যাট্রিবিউট

  4. HTML pattern অ্যাট্রিবিউট